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