|
|
|
@ -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 ); |
|
|
|
|
|
|
|
|
@ -67,6 +79,11 @@ function generateQuery( clean ){
|
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// run the address parser
|
|
|
|
|
if( clean.parsed_text ){ |
|
|
|
|
textParser( clean.parsed_text, vs ); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var q = query.render( vs ); |
|
|
|
|
|
|
|
|
|
console.log( JSON.stringify( q, null, 2 ) ); |
|
|
|
|