Browse Source

more tweaks

pull/378/head
Peter Johnson 9 years ago
parent
commit
3d29b09805
  1. 65
      query/autocomplete.js
  2. 2
      query/autocomplete_defaults.js

65
query/autocomplete.js

@ -48,32 +48,17 @@ var phrase_first_only = function( vs ){
return phrase( vs2 );
};
//------------------------------
// autocomplete query
//------------------------------
var query = new peliasQuery.layout.FilteredBooleanQuery();
// mandatory matches
query.score( phrase_first_only, 'must' );
query.score( ngrams_last_only, 'must' );
var simpleNgramsView = function( vs ){
// address components
query.score( peliasQuery.view.address('housenumber') );
query.score( peliasQuery.view.address('street') );
query.score( peliasQuery.view.address('postcode') );
var view = ngrams( vs );
// 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') );
view.match['name.default'].analyzer = 'peliasPhrase';
delete view.match['name.default'].type;
delete view.match['name.default'].boost;
// scoring boost
// query.score( phrase );
// console.log( JSON.stringify( view, null, 2 ) );
return view;
};
var focus = peliasQuery.view.focus( ngrams );
var localView = function( vs ){
@ -81,6 +66,7 @@ var localView = function( vs ){
var view = focus( vs );
if( view && view.hasOwnProperty('function_score') ){
view.function_score.query.match['name.default'].analyzer = 'peliasPhrase';
view.function_score.filter = {
'or': [
{ 'type': { 'value': 'osmnode' } },
@ -95,20 +81,35 @@ var localView = function( vs ){
return view;
};
// console.log( focus );
//------------------------------
// autocomplete query
//------------------------------
var query = new peliasQuery.layout.FilteredBooleanQuery();
query.score( localView );
// mandatory matches
query.score( phrase_first_only, 'must' );
query.score( ngrams_last_only, 'must' );
var simpleNgramsView = function( vs ){
// address components
query.score( peliasQuery.view.address('housenumber') );
query.score( peliasQuery.view.address('street') );
query.score( peliasQuery.view.address('postcode') );
var view = ngrams( vs );
// 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') );
delete view.match['name.default'].type;
delete view.match['name.default'].boost;
// scoring boost
// query.score( phrase );
// console.log( JSON.stringify( view, null, 2 ) );
return view;
};
// console.log( focus );
query.score( localView );
query.score( peliasQuery.view.popularity( simpleNgramsView ) );
query.score( peliasQuery.view.population( simpleNgramsView ) );

2
query/autocomplete_defaults.js

@ -30,7 +30,7 @@ module.exports = extend( false, peliasQuery.defaults, {
'phrase:slop': 2,
'focus:function': 'linear',
'focus:offset': '100km',
'focus:offset': '10km',
'focus:scale': '250km',
'focus:decay': 0.5,
'focus:weight': 4,

Loading…
Cancel
Save