Browse Source

autocomplete tweaks

pull/378/head
Peter Johnson 9 years ago
parent
commit
35d48dc154
  1. 30
      query/autocomplete.js
  2. 8
      query/autocomplete_defaults.js

30
query/autocomplete.js

@ -13,7 +13,29 @@ query.score( peliasQuery.view.ngrams, 'must' );
// scoring boost
query.score( peliasQuery.view.phrase );
query.score( peliasQuery.view.focus( peliasQuery.view.ngrams ) );
var focus = peliasQuery.view.focus( peliasQuery.view.phrase );
var _tmpview = function( vs ){
var view = focus( vs );
view.function_score.filter = {
'or': [
{ 'type': { 'value': 'osmnode' } },
{ 'type': { 'value': 'osmway' } },
{ 'type': { 'value': 'osmaddress' } },
{ 'type': { 'value': 'openaddresses' } },
{ 'type': { 'value': 'geoname' } },
]
};
// console.log( JSON.stringify( view, null, 2 ) );
return view;
};
// console.log( focus );
query.score( _tmpview );
query.score( peliasQuery.view.popularity( peliasQuery.view.phrase ) );
query.score( peliasQuery.view.population( peliasQuery.view.phrase ) );
@ -42,7 +64,11 @@ function generateQuery( clean ){
});
}
return query.render( vs );
var q = query.render( vs );
console.log( JSON.stringify( q, null, 2 ) );
return q;
}
module.exports = generateQuery;

8
query/autocomplete_defaults.js

@ -30,13 +30,13 @@ module.exports = extend( false, peliasQuery.defaults, {
'phrase:slop': 2,
'focus:function': 'linear',
'focus:offset': '1km',
'focus:scale': '50km',
'focus:offset': '100km',
'focus:scale': '250km',
'focus:decay': 0.5,
'focus:weight': 2,
'focus:weight': 10,
'function_score:score_mode': 'avg',
'function_score:boost_mode': 'replace',
'function_score:boost_mode': 'multiply',
'address:housenumber:analyzer': 'peliasHousenumber',
'address:housenumber:field': 'address.number',

Loading…
Cancel
Save