Browse Source

enable text parsing

pull/382/head
Peter Johnson 9 years ago committed by Julian Simioni
parent
commit
609fc4e699
  1. 17
      query/autocomplete.js

17
query/autocomplete.js

@ -1,8 +1,10 @@
var peliasQuery = require('pelias-query'), var peliasQuery = require('pelias-query'),
defaults = require('./autocomplete_defaults'), defaults = require('./autocomplete_defaults'),
textParser = require('./text_parser'),
check = require('check-types'); check = require('check-types');
//------------------------------ //------------------------------
// autocomplete query // autocomplete query
//------------------------------ //------------------------------
@ -11,6 +13,16 @@ var query = new peliasQuery.layout.FilteredBooleanQuery();
// mandatory matches // mandatory matches
query.score( peliasQuery.view.ngrams, 'must' ); 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 // scoring boost
query.score( peliasQuery.view.phrase ); query.score( peliasQuery.view.phrase );
query.score( peliasQuery.view.focus( peliasQuery.view.ngrams ) ); 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 ); return query.render( vs );
} }

Loading…
Cancel
Save