diff --git a/package.json b/package.json index abca960e..da77a3df 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "pelias-config": "^1.0.1", "pelias-esclient": "0.0.25", "pelias-logger": "^0.0.8", - "pelias-query": "2.0.0", + "pelias-query": "^5.0.0", "pelias-schema": "1.0.0", "pelias-suggester-pipeline": "2.0.2", "stats-lite": "^1.0.3", diff --git a/query/autocomplete.js b/query/autocomplete.js index 62fb775e..ad64413a 100644 --- a/query/autocomplete.js +++ b/query/autocomplete.js @@ -14,7 +14,8 @@ query.score( peliasQuery.view.ngrams, 'must' ); // scoring boost query.score( peliasQuery.view.phrase ); query.score( peliasQuery.view.focus( peliasQuery.view.ngrams ) ); -query.score( peliasQuery.view.popularity(['admin0','admin1','admin2']) ); +query.score( peliasQuery.view.popularity( peliasQuery.view.phrase ) ); +query.score( peliasQuery.view.population( peliasQuery.view.phrase ) ); // -------------------------------- diff --git a/query/defaults.js b/query/defaults.js index 83ddb4d9..b61e84ac 100644 --- a/query/defaults.js +++ b/query/defaults.js @@ -8,7 +8,7 @@ module.exports = extend( false, peliasQuery.defaults, { 'track_scores': true, 'centroid:field': 'center_point', - + 'sort:distance:order': 'asc', 'sort:distance:distance_type': 'plane', @@ -33,6 +33,7 @@ module.exports = extend( false, peliasQuery.defaults, { 'focus:offset': '1km', 'focus:scale': '50km', 'focus:decay': 0.5, + 'focus:weight': 2, 'function_score:score_mode': 'avg', 'function_score:boost_mode': 'replace', @@ -79,6 +80,16 @@ module.exports = extend( false, peliasQuery.defaults, { 'admin:neighborhood:analyzer': 'peliasAdmin', 'admin:neighborhood:field': 'neighborhood', - 'admin:neighborhood:boost': 1 + 'admin:neighborhood:boost': 1, + + 'popularity:field': 'popularity', + 'popularity:modifier': 'log1p', + 'popularity:max_boost': 20, + 'popularity:weight': 1, + + 'population:field': 'population', + 'population:modifier': 'log1p', + 'population:max_boost': 20, + 'population:weight': 2 -}); \ No newline at end of file +}); diff --git a/query/reverse.js b/query/reverse.js index 9401f916..fd84b427 100644 --- a/query/reverse.js +++ b/query/reverse.js @@ -44,7 +44,7 @@ function generateQuery( clean ){ // bounding circle // note: the sanitizers will take care of the case - // where point.lan/point.lon are provided in the + // where point.lan/point.lon are provided in the // absense of boundary.circle.lat/boundary.circle.lon if( check.number(clean['boundary.circle.lat']) && check.number(clean['boundary.circle.lon']) && diff --git a/query/search.js b/query/search.js index a3787535..3eeb8798 100644 --- a/query/search.js +++ b/query/search.js @@ -15,7 +15,8 @@ query.score( peliasQuery.view.ngrams, 'must' ); // scoring boost query.score( peliasQuery.view.phrase ); query.score( peliasQuery.view.focus( peliasQuery.view.phrase ) ); -query.score( peliasQuery.view.popularity(['admin0','admin1','admin2']) ); +query.score( peliasQuery.view.popularity( peliasQuery.view.phrase ) ); +query.score( peliasQuery.view.population( peliasQuery.view.phrase ) ); // address components query.score( peliasQuery.view.address('housenumber') ); diff --git a/test/unit/fixture/autocomplete_linguistic_focus.js b/test/unit/fixture/autocomplete_linguistic_focus.js index 2049bf0b..8d0e9914 100644 --- a/test/unit/fixture/autocomplete_linguistic_focus.js +++ b/test/unit/fixture/autocomplete_linguistic_focus.js @@ -45,53 +45,70 @@ module.exports = { 'scale': '50km', 'decay': 0.5 } - } + }, + 'weight': 2 }], 'score_mode': 'avg', 'boost_mode': 'replace' } - }, - { + },{ 'function_score': { 'query': { - 'filtered': { - 'filter': { - 'exists': { - 'field': 'popularity' - } + 'match': { + 'phrase.default': { + 'query': 'test', + 'analyzer': 'peliasPhrase', + 'type': 'phrase', + 'slop': 2, + 'boost': 1 } } }, - 'max_boost': 2, + 'max_boost': 20, 'score_mode': 'first', 'boost_mode': 'replace', 'filter': { - 'or': [ - { - 'type': { - 'value': 'admin0' - } - }, - { - 'type': { - 'value': 'admin1' - } - }, - { - 'type': { - 'value': 'admin2' - } - } - ] + 'exists': { + 'field': 'popularity' + } }, 'functions': [{ 'field_value_factor': { - 'modifier': 'sqrt', + 'modifier': 'log1p', 'field': 'popularity' }, 'weight': 1 }] } + },{ + 'function_score': { + 'query': { + 'match': { + 'phrase.default': { + 'query': 'test', + 'analyzer': 'peliasPhrase', + 'type': 'phrase', + 'slop': 2, + 'boost': 1 + } + } + }, + 'max_boost': 20, + 'score_mode': 'first', + 'boost_mode': 'replace', + 'filter': { + 'exists': { + 'field': 'population' + } + }, + 'functions': [{ + 'field_value_factor': { + 'modifier': 'log1p', + 'field': 'population' + }, + 'weight': 2 + }] + } }] } } @@ -100,4 +117,4 @@ module.exports = { 'sort': [ '_score' ], 'size': 10, 'track_scores': true -}; \ No newline at end of file +}; diff --git a/test/unit/fixture/autocomplete_linguistic_focus_null_island.js b/test/unit/fixture/autocomplete_linguistic_focus_null_island.js index 57d4747c..8300b026 100644 --- a/test/unit/fixture/autocomplete_linguistic_focus_null_island.js +++ b/test/unit/fixture/autocomplete_linguistic_focus_null_island.js @@ -45,53 +45,70 @@ module.exports = { 'scale': '50km', 'decay': 0.5 } - } + }, + 'weight': 2 }], 'score_mode': 'avg', 'boost_mode': 'replace' } - }, - { + },{ 'function_score': { 'query': { - 'filtered': { - 'filter': { - 'exists': { - 'field': 'popularity' - } + 'match': { + 'phrase.default': { + 'query': 'test', + 'analyzer': 'peliasPhrase', + 'type': 'phrase', + 'slop': 2, + 'boost': 1 } } }, - 'max_boost': 2, + 'max_boost': 20, 'score_mode': 'first', 'boost_mode': 'replace', 'filter': { - 'or': [ - { - 'type': { - 'value': 'admin0' - } - }, - { - 'type': { - 'value': 'admin1' - } - }, - { - 'type': { - 'value': 'admin2' - } - } - ] + 'exists': { + 'field': 'popularity' + } }, 'functions': [{ 'field_value_factor': { - 'modifier': 'sqrt', + 'modifier': 'log1p', 'field': 'popularity' }, 'weight': 1 }] } + },{ + 'function_score': { + 'query': { + 'match': { + 'phrase.default': { + 'query': 'test', + 'analyzer': 'peliasPhrase', + 'type': 'phrase', + 'slop': 2, + 'boost': 1 + } + } + }, + 'max_boost': 20, + 'score_mode': 'first', + 'boost_mode': 'replace', + 'filter': { + 'exists': { + 'field': 'population' + } + }, + 'functions': [{ + 'field_value_factor': { + 'modifier': 'log1p', + 'field': 'population' + }, + 'weight': 2 + }] + } }] } } diff --git a/test/unit/fixture/autocomplete_linguistic_only.js b/test/unit/fixture/autocomplete_linguistic_only.js index ac059ef1..53ece28e 100644 --- a/test/unit/fixture/autocomplete_linguistic_only.js +++ b/test/unit/fixture/autocomplete_linguistic_only.js @@ -23,48 +23,64 @@ module.exports = { 'slop': 2 } } - }, - { + },{ 'function_score': { 'query': { - 'filtered': { - 'filter': { - 'exists': { - 'field': 'popularity' - } + 'match': { + 'phrase.default': { + 'query': 'test', + 'analyzer': 'peliasPhrase', + 'type': 'phrase', + 'slop': 2, + 'boost': 1 } } }, - 'max_boost': 2, + 'max_boost': 20, 'score_mode': 'first', 'boost_mode': 'replace', 'filter': { - 'or': [ - { - 'type': { - 'value': 'admin0' - } - }, - { - 'type': { - 'value': 'admin1' - } - }, - { - 'type': { - 'value': 'admin2' - } - } - ] + 'exists': { + 'field': 'popularity' + } }, 'functions': [{ 'field_value_factor': { - 'modifier': 'sqrt', + 'modifier': 'log1p', 'field': 'popularity' }, 'weight': 1 }] } + },{ + 'function_score': { + 'query': { + 'match': { + 'phrase.default': { + 'query': 'test', + 'analyzer': 'peliasPhrase', + 'type': 'phrase', + 'slop': 2, + 'boost': 1 + } + } + }, + 'max_boost': 20, + 'score_mode': 'first', + 'boost_mode': 'replace', + 'filter': { + 'exists': { + 'field': 'population' + } + }, + 'functions': [{ + 'field_value_factor': { + 'modifier': 'log1p', + 'field': 'population' + }, + 'weight': 2 + }] + } }] } } @@ -73,4 +89,4 @@ module.exports = { 'sort': [ '_score' ], 'size': 10, 'track_scores': true -}; \ No newline at end of file +}; diff --git a/test/unit/fixture/search_boundary_country.js b/test/unit/fixture/search_boundary_country.js index a75a8091..3e6f83bc 100644 --- a/test/unit/fixture/search_boundary_country.js +++ b/test/unit/fixture/search_boundary_country.js @@ -33,48 +33,64 @@ module.exports = { 'slop': 2 } } - }, - { + },{ 'function_score': { 'query': { - 'filtered': { - 'filter': { - 'exists': { - 'field': 'popularity' - } + 'match': { + 'phrase.default': { + 'query': 'test', + 'analyzer': 'peliasPhrase', + 'type': 'phrase', + 'slop': 2, + 'boost': 1 } } }, - 'max_boost': 2, + 'max_boost': 20, 'score_mode': 'first', 'boost_mode': 'replace', 'filter': { - 'or': [ - { - 'type': { - 'value': 'admin0' - } - }, - { - 'type': { - 'value': 'admin1' - } - }, - { - 'type': { - 'value': 'admin2' - } - } - ] + 'exists': { + 'field': 'popularity' + } }, 'functions': [{ 'field_value_factor': { - 'modifier': 'sqrt', + 'modifier': 'log1p', 'field': 'popularity' }, 'weight': 1 }] } + },{ + 'function_score': { + 'query': { + 'match': { + 'phrase.default': { + 'query': 'test', + 'analyzer': 'peliasPhrase', + 'type': 'phrase', + 'slop': 2, + 'boost': 1 + } + } + }, + 'max_boost': 20, + 'score_mode': 'first', + 'boost_mode': 'replace', + 'filter': { + 'exists': { + 'field': 'population' + } + }, + 'functions': [{ + 'field_value_factor': { + 'modifier': 'log1p', + 'field': 'population' + }, + 'weight': 2 + }] + } }] } } diff --git a/test/unit/fixture/search_full_address.js b/test/unit/fixture/search_full_address.js index aff242b8..93572705 100644 --- a/test/unit/fixture/search_full_address.js +++ b/test/unit/fixture/search_full_address.js @@ -30,44 +30,61 @@ module.exports = { { 'function_score': { 'query': { - 'filtered': { - 'filter': { - 'exists': { - 'field': 'popularity' - } + 'match': { + 'phrase.default': { + 'query': '123 main st', + 'analyzer': 'peliasPhrase', + 'type': 'phrase', + 'slop': 2, + 'boost': 1 } } }, - 'max_boost': 2, + 'max_boost': 20, 'score_mode': 'first', 'boost_mode': 'replace', 'filter': { - 'or': [ - { - 'type': { - 'value': 'admin0' - } - }, - { - 'type': { - 'value': 'admin1' - } - }, - { - 'type': { - 'value': 'admin2' - } - } - ] + 'exists': { + 'field': 'popularity' + } }, 'functions': [{ 'field_value_factor': { - 'modifier': 'sqrt', + 'modifier': 'log1p', 'field': 'popularity' }, 'weight': 1 }] } + },{ + 'function_score': { + 'query': { + 'match': { + 'phrase.default': { + 'query': '123 main st', + 'analyzer': 'peliasPhrase', + 'type': 'phrase', + 'slop': 2, + 'boost': 1 + } + } + }, + 'max_boost': 20, + 'score_mode': 'first', + 'boost_mode': 'replace', + 'filter': { + 'exists': { + 'field': 'population' + } + }, + 'functions': [{ + 'field_value_factor': { + 'modifier': 'log1p', + 'field': 'population' + }, + 'weight': 2 + }] + } },{ 'match': { 'address.number': { @@ -164,4 +181,4 @@ module.exports = { 'size': 10, 'sort': [ '_score' ], 'track_scores': true -}; \ No newline at end of file +}; diff --git a/test/unit/fixture/search_linguistic_bbox.js b/test/unit/fixture/search_linguistic_bbox.js index 6c98b010..6e6676d5 100644 --- a/test/unit/fixture/search_linguistic_bbox.js +++ b/test/unit/fixture/search_linguistic_bbox.js @@ -23,48 +23,64 @@ module.exports = { 'slop': 2 } } - }, - { + },{ 'function_score': { 'query': { - 'filtered': { - 'filter': { - 'exists': { - 'field': 'popularity' - } + 'match': { + 'phrase.default': { + 'query': 'test', + 'analyzer': 'peliasPhrase', + 'type': 'phrase', + 'slop': 2, + 'boost': 1 } } }, - 'max_boost': 2, + 'max_boost': 20, 'score_mode': 'first', 'boost_mode': 'replace', 'filter': { - 'or': [ - { - 'type': { - 'value': 'admin0' - } - }, - { - 'type': { - 'value': 'admin1' - } - }, - { - 'type': { - 'value': 'admin2' - } - } - ] + 'exists': { + 'field': 'popularity' + } }, 'functions': [{ 'field_value_factor': { - 'modifier': 'sqrt', + 'modifier': 'log1p', 'field': 'popularity' }, 'weight': 1 }] } + },{ + 'function_score': { + 'query': { + 'match': { + 'phrase.default': { + 'query': 'test', + 'analyzer': 'peliasPhrase', + 'type': 'phrase', + 'slop': 2, + 'boost': 1 + } + } + }, + 'max_boost': 20, + 'score_mode': 'first', + 'boost_mode': 'replace', + 'filter': { + 'exists': { + 'field': 'population' + } + }, + 'functions': [{ + 'field_value_factor': { + 'modifier': 'log1p', + 'field': 'population' + }, + 'weight': 2 + }] + } }] } }, @@ -89,4 +105,4 @@ module.exports = { 'sort': [ '_sort' ], 'size': 10, 'track_scores': true -}; \ No newline at end of file +}; diff --git a/test/unit/fixture/search_linguistic_focus.js b/test/unit/fixture/search_linguistic_focus.js index 072bca64..36cb2912 100644 --- a/test/unit/fixture/search_linguistic_focus.js +++ b/test/unit/fixture/search_linguistic_focus.js @@ -47,53 +47,70 @@ module.exports = { 'scale': '50km', 'decay': 0.5 } - } + }, + 'weight': 2 }], 'score_mode': 'avg', 'boost_mode': 'replace' } - }, - { + },{ 'function_score': { 'query': { - 'filtered': { - 'filter': { - 'exists': { - 'field': 'popularity' - } + 'match': { + 'phrase.default': { + 'query': 'test', + 'analyzer': 'peliasPhrase', + 'type': 'phrase', + 'slop': 2, + 'boost': 1 } } }, - 'max_boost': 2, + 'max_boost': 20, 'score_mode': 'first', 'boost_mode': 'replace', 'filter': { - 'or': [ - { - 'type': { - 'value': 'admin0' - } - }, - { - 'type': { - 'value': 'admin1' - } - }, - { - 'type': { - 'value': 'admin2' - } - } - ] + 'exists': { + 'field': 'popularity' + } }, 'functions': [{ 'field_value_factor': { - 'modifier': 'sqrt', + 'modifier': 'log1p', 'field': 'popularity' }, 'weight': 1 }] } + },{ + 'function_score': { + 'query': { + 'match': { + 'phrase.default': { + 'query': 'test', + 'analyzer': 'peliasPhrase', + 'type': 'phrase', + 'slop': 2, + 'boost': 1 + } + } + }, + 'max_boost': 20, + 'score_mode': 'first', + 'boost_mode': 'replace', + 'filter': { + 'exists': { + 'field': 'population' + } + }, + 'functions': [{ + 'field_value_factor': { + 'modifier': 'log1p', + 'field': 'population' + }, + 'weight': 2 + }] + } }] } } @@ -102,4 +119,4 @@ module.exports = { 'sort': [ '_sort' ], 'size': 10, 'track_scores': true -}; \ No newline at end of file +}; diff --git a/test/unit/fixture/search_linguistic_focus_bbox.js b/test/unit/fixture/search_linguistic_focus_bbox.js index e6a04824..4932d56b 100644 --- a/test/unit/fixture/search_linguistic_focus_bbox.js +++ b/test/unit/fixture/search_linguistic_focus_bbox.js @@ -47,53 +47,70 @@ module.exports = { 'scale': '50km', 'decay': 0.5 } - } + }, + 'weight': 2 }], 'score_mode': 'avg', 'boost_mode': 'replace' } - }, - { + },{ 'function_score': { 'query': { - 'filtered': { - 'filter': { - 'exists': { - 'field': 'popularity' - } + 'match': { + 'phrase.default': { + 'query': 'test', + 'analyzer': 'peliasPhrase', + 'type': 'phrase', + 'slop': 2, + 'boost': 1 } } }, - 'max_boost': 2, + 'max_boost': 20, 'score_mode': 'first', 'boost_mode': 'replace', 'filter': { - 'or': [ - { - 'type': { - 'value': 'admin0' - } - }, - { - 'type': { - 'value': 'admin1' - } - }, - { - 'type': { - 'value': 'admin2' - } - } - ] + 'exists': { + 'field': 'popularity' + } }, 'functions': [{ 'field_value_factor': { - 'modifier': 'sqrt', + 'modifier': 'log1p', 'field': 'popularity' }, 'weight': 1 }] } + },{ + 'function_score': { + 'query': { + 'match': { + 'phrase.default': { + 'query': 'test', + 'analyzer': 'peliasPhrase', + 'type': 'phrase', + 'slop': 2, + 'boost': 1 + } + } + }, + 'max_boost': 20, + 'score_mode': 'first', + 'boost_mode': 'replace', + 'filter': { + 'exists': { + 'field': 'population' + } + }, + 'functions': [{ + 'field_value_factor': { + 'modifier': 'log1p', + 'field': 'population' + }, + 'weight': 2 + }] + } }] } }, @@ -118,4 +135,4 @@ module.exports = { 'sort': [ '_sort' ], 'size': 10, 'track_scores': true -}; \ No newline at end of file +}; diff --git a/test/unit/fixture/search_linguistic_focus_null_island.js b/test/unit/fixture/search_linguistic_focus_null_island.js index 832aa9f7..04116c55 100644 --- a/test/unit/fixture/search_linguistic_focus_null_island.js +++ b/test/unit/fixture/search_linguistic_focus_null_island.js @@ -47,53 +47,70 @@ module.exports = { 'scale': '50km', 'decay': 0.5 } - } + }, + 'weight': 2 }], 'score_mode': 'avg', 'boost_mode': 'replace' } - }, - { + },{ 'function_score': { 'query': { - 'filtered': { - 'filter': { - 'exists': { - 'field': 'popularity' - } + 'match': { + 'phrase.default': { + 'query': 'test', + 'analyzer': 'peliasPhrase', + 'type': 'phrase', + 'slop': 2, + 'boost': 1 } } }, - 'max_boost': 2, + 'max_boost': 20, 'score_mode': 'first', 'boost_mode': 'replace', 'filter': { - 'or': [ - { - 'type': { - 'value': 'admin0' - } - }, - { - 'type': { - 'value': 'admin1' - } - }, - { - 'type': { - 'value': 'admin2' - } - } - ] + 'exists': { + 'field': 'popularity' + } }, 'functions': [{ 'field_value_factor': { - 'modifier': 'sqrt', + 'modifier': 'log1p', 'field': 'popularity' }, 'weight': 1 }] } + },{ + 'function_score': { + 'query': { + 'match': { + 'phrase.default': { + 'query': 'test', + 'analyzer': 'peliasPhrase', + 'type': 'phrase', + 'slop': 2, + 'boost': 1 + } + } + }, + 'max_boost': 20, + 'score_mode': 'first', + 'boost_mode': 'replace', + 'filter': { + 'exists': { + 'field': 'population' + } + }, + 'functions': [{ + 'field_value_factor': { + 'modifier': 'log1p', + 'field': 'population' + }, + 'weight': 2 + }] + } }] } } diff --git a/test/unit/fixture/search_linguistic_only.js b/test/unit/fixture/search_linguistic_only.js index ac059ef1..53ece28e 100644 --- a/test/unit/fixture/search_linguistic_only.js +++ b/test/unit/fixture/search_linguistic_only.js @@ -23,48 +23,64 @@ module.exports = { 'slop': 2 } } - }, - { + },{ 'function_score': { 'query': { - 'filtered': { - 'filter': { - 'exists': { - 'field': 'popularity' - } + 'match': { + 'phrase.default': { + 'query': 'test', + 'analyzer': 'peliasPhrase', + 'type': 'phrase', + 'slop': 2, + 'boost': 1 } } }, - 'max_boost': 2, + 'max_boost': 20, 'score_mode': 'first', 'boost_mode': 'replace', 'filter': { - 'or': [ - { - 'type': { - 'value': 'admin0' - } - }, - { - 'type': { - 'value': 'admin1' - } - }, - { - 'type': { - 'value': 'admin2' - } - } - ] + 'exists': { + 'field': 'popularity' + } }, 'functions': [{ 'field_value_factor': { - 'modifier': 'sqrt', + 'modifier': 'log1p', 'field': 'popularity' }, 'weight': 1 }] } + },{ + 'function_score': { + 'query': { + 'match': { + 'phrase.default': { + 'query': 'test', + 'analyzer': 'peliasPhrase', + 'type': 'phrase', + 'slop': 2, + 'boost': 1 + } + } + }, + 'max_boost': 20, + 'score_mode': 'first', + 'boost_mode': 'replace', + 'filter': { + 'exists': { + 'field': 'population' + } + }, + 'functions': [{ + 'field_value_factor': { + 'modifier': 'log1p', + 'field': 'population' + }, + 'weight': 2 + }] + } }] } } @@ -73,4 +89,4 @@ module.exports = { 'sort': [ '_score' ], 'size': 10, 'track_scores': true -}; \ No newline at end of file +}; diff --git a/test/unit/fixture/search_partial_address.js b/test/unit/fixture/search_partial_address.js index 94210bf5..6e0fbd5b 100644 --- a/test/unit/fixture/search_partial_address.js +++ b/test/unit/fixture/search_partial_address.js @@ -26,48 +26,64 @@ module.exports = { 'boost': 1 } } - }, - { + },{ 'function_score': { 'query': { - 'filtered': { - 'filter': { - 'exists': { - 'field': 'popularity' - } + 'match': { + 'phrase.default': { + 'query': 'soho grand', + 'analyzer': 'peliasPhrase', + 'type': 'phrase', + 'slop': 2, + 'boost': 1 } } }, - 'max_boost': 2, + 'max_boost': 20, 'score_mode': 'first', 'boost_mode': 'replace', 'filter': { - 'or': [ - { - 'type': { - 'value': 'admin0' - } - }, - { - 'type': { - 'value': 'admin1' - } - }, - { - 'type': { - 'value': 'admin2' - } - } - ] + 'exists': { + 'field': 'popularity' + } }, 'functions': [{ 'field_value_factor': { - 'modifier': 'sqrt', + 'modifier': 'log1p', 'field': 'popularity' }, 'weight': 1 }] } + },{ + 'function_score': { + 'query': { + 'match': { + 'phrase.default': { + 'query': 'soho grand', + 'analyzer': 'peliasPhrase', + 'type': 'phrase', + 'slop': 2, + 'boost': 1 + } + } + }, + 'max_boost': 20, + 'score_mode': 'first', + 'boost_mode': 'replace', + 'filter': { + 'exists': { + 'field': 'population' + } + }, + 'functions': [{ + 'field_value_factor': { + 'modifier': 'log1p', + 'field': 'population' + }, + 'weight': 2 + }] + } },{ 'match': { 'admin0': { @@ -132,4 +148,4 @@ module.exports = { 'size': 10, 'sort': [ '_score' ], 'track_scores': true -}; \ No newline at end of file +}; diff --git a/test/unit/fixture/search_regions_address.js b/test/unit/fixture/search_regions_address.js index 05d4ffe5..cc04943b 100644 --- a/test/unit/fixture/search_regions_address.js +++ b/test/unit/fixture/search_regions_address.js @@ -26,48 +26,64 @@ module.exports = { 'boost': 1 } } - }, - { + },{ 'function_score': { 'query': { - 'filtered': { - 'filter': { - 'exists': { - 'field': 'popularity' - } + 'match': { + 'phrase.default': { + 'query': '1 water st', + 'analyzer': 'peliasPhrase', + 'type': 'phrase', + 'slop': 2, + 'boost': 1 } } }, - 'max_boost': 2, + 'max_boost': 20, 'score_mode': 'first', 'boost_mode': 'replace', 'filter': { - 'or': [ - { - 'type': { - 'value': 'admin0' - } - }, - { - 'type': { - 'value': 'admin1' - } - }, - { - 'type': { - 'value': 'admin2' - } - } - ] + 'exists': { + 'field': 'popularity' + } }, 'functions': [{ 'field_value_factor': { - 'modifier': 'sqrt', + 'modifier': 'log1p', 'field': 'popularity' }, 'weight': 1 }] } + },{ + 'function_score': { + 'query': { + 'match': { + 'phrase.default': { + 'query': '1 water st', + 'analyzer': 'peliasPhrase', + 'type': 'phrase', + 'slop': 2, + 'boost': 1 + } + } + }, + 'max_boost': 20, + 'score_mode': 'first', + 'boost_mode': 'replace', + 'filter': { + 'exists': { + 'field': 'population' + } + }, + 'functions': [{ + 'field_value_factor': { + 'modifier': 'log1p', + 'field': 'population' + }, + 'weight': 2 + }] + } },{ 'match': { 'address.number': { @@ -148,4 +164,4 @@ module.exports = { 'size': 10, 'sort': [ '_score' ], 'track_scores': true -}; \ No newline at end of file +};