|
|
|
@ -1,8 +1,10 @@
|
|
|
|
|
|
|
|
|
|
var peliasQuery = require('pelias-query'), |
|
|
|
|
defaults = require('./autocomplete_defaults'), |
|
|
|
|
textParser = require('./text_parser'), |
|
|
|
|
check = require('check-types'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//------------------------------
|
|
|
|
|
// autocomplete query
|
|
|
|
|
//------------------------------
|
|
|
|
@ -11,6 +13,16 @@ var query = new peliasQuery.layout.FilteredBooleanQuery();
|
|
|
|
|
// mandatory matches
|
|
|
|
|
query.score( peliasQuery.view.ngrams, 'must' ); |
|
|
|
|
|
|
|
|
|
// admin components
|
|
|
|
|
query.score( peliasQuery.view.admin('alpha3') ); |
|
|
|
|
query.score( peliasQuery.view.admin('admin0') ); |
|
|
|
|
query.score( peliasQuery.view.admin('admin1') ); |
|
|
|
|
query.score( peliasQuery.view.admin('admin1_abbr') ); |
|
|
|
|
query.score( peliasQuery.view.admin('admin2') ); |
|
|
|
|
query.score( peliasQuery.view.admin('local_admin') ); |
|
|
|
|
query.score( peliasQuery.view.admin('locality') ); |
|
|
|
|
query.score( peliasQuery.view.admin('neighborhood') ); |
|
|
|
|
|
|
|
|
|
// scoring boost
|
|
|
|
|
query.score( peliasQuery.view.phrase ); |
|
|
|
|
query.score( peliasQuery.view.focus( peliasQuery.view.ngrams ) ); |
|
|
|
@ -39,6 +51,11 @@ function generateQuery( clean ){
|
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// run the address parser
|
|
|
|
|
if( clean.parsed_text ){ |
|
|
|
|
textParser( clean.parsed_text, vs ); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return query.render( vs ); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|