diff --git a/package.json b/package.json index abca960e..9cf371b9 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": "4.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..7b761ae6 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', @@ -79,6 +79,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': 'sqrt', + 'popularity:max_boost': 10000, + 'popularity:weight': 1, + + 'population:field': 'population', + 'population:modifier': 'sqrt', + 'population:max_boost': 2000, + 'population:weight': 1 -}); \ 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..31404731 100644 --- a/test/unit/fixture/autocomplete_linguistic_focus.js +++ b/test/unit/fixture/autocomplete_linguistic_focus.js @@ -50,39 +50,26 @@ module.exports = { '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': 10000, 'score_mode': 'first', 'boost_mode': 'replace', 'filter': { - 'or': [ - { - 'type': { - 'value': 'admin0' - } - }, - { - 'type': { - 'value': 'admin1' - } - }, - { - 'type': { - 'value': 'admin2' - } - } - ] + 'exists': { + 'field': 'popularity' + } }, 'functions': [{ 'field_value_factor': { @@ -92,6 +79,35 @@ module.exports = { 'weight': 1 }] } + },{ + 'function_score': { + 'query': { + 'match': { + 'phrase.default': { + 'query': 'test', + 'analyzer': 'peliasPhrase', + 'type': 'phrase', + 'slop': 2, + 'boost': 1 + } + } + }, + 'max_boost': 2000, + 'score_mode': 'first', + 'boost_mode': 'replace', + 'filter': { + 'exists': { + 'field': 'population' + } + }, + 'functions': [{ + 'field_value_factor': { + 'modifier': 'sqrt', + 'field': 'population' + }, + 'weight': 1 + }] + } }] } } @@ -100,4 +116,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..2f46b9b0 100644 --- a/test/unit/fixture/autocomplete_linguistic_focus_null_island.js +++ b/test/unit/fixture/autocomplete_linguistic_focus_null_island.js @@ -50,39 +50,26 @@ module.exports = { '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': 10000, 'score_mode': 'first', 'boost_mode': 'replace', 'filter': { - 'or': [ - { - 'type': { - 'value': 'admin0' - } - }, - { - 'type': { - 'value': 'admin1' - } - }, - { - 'type': { - 'value': 'admin2' - } - } - ] + 'exists': { + 'field': 'popularity' + } }, 'functions': [{ 'field_value_factor': { @@ -92,6 +79,35 @@ module.exports = { 'weight': 1 }] } + },{ + 'function_score': { + 'query': { + 'match': { + 'phrase.default': { + 'query': 'test', + 'analyzer': 'peliasPhrase', + 'type': 'phrase', + 'slop': 2, + 'boost': 1 + } + } + }, + 'max_boost': 2000, + 'score_mode': 'first', + 'boost_mode': 'replace', + 'filter': { + 'exists': { + 'field': 'population' + } + }, + 'functions': [{ + 'field_value_factor': { + 'modifier': 'sqrt', + 'field': 'population' + }, + 'weight': 1 + }] + } }] } } diff --git a/test/unit/fixture/autocomplete_linguistic_only.js b/test/unit/fixture/autocomplete_linguistic_only.js index ac059ef1..65db3fc8 100644 --- a/test/unit/fixture/autocomplete_linguistic_only.js +++ b/test/unit/fixture/autocomplete_linguistic_only.js @@ -23,39 +23,26 @@ 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': 10000, 'score_mode': 'first', 'boost_mode': 'replace', 'filter': { - 'or': [ - { - 'type': { - 'value': 'admin0' - } - }, - { - 'type': { - 'value': 'admin1' - } - }, - { - 'type': { - 'value': 'admin2' - } - } - ] + 'exists': { + 'field': 'popularity' + } }, 'functions': [{ 'field_value_factor': { @@ -65,6 +52,35 @@ module.exports = { 'weight': 1 }] } + },{ + 'function_score': { + 'query': { + 'match': { + 'phrase.default': { + 'query': 'test', + 'analyzer': 'peliasPhrase', + 'type': 'phrase', + 'slop': 2, + 'boost': 1 + } + } + }, + 'max_boost': 2000, + 'score_mode': 'first', + 'boost_mode': 'replace', + 'filter': { + 'exists': { + 'field': 'population' + } + }, + 'functions': [{ + 'field_value_factor': { + 'modifier': 'sqrt', + 'field': 'population' + }, + 'weight': 1 + }] + } }] } } @@ -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..76f2c44c 100644 --- a/test/unit/fixture/search_boundary_country.js +++ b/test/unit/fixture/search_boundary_country.js @@ -33,39 +33,26 @@ 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': 10000, 'score_mode': 'first', 'boost_mode': 'replace', 'filter': { - 'or': [ - { - 'type': { - 'value': 'admin0' - } - }, - { - 'type': { - 'value': 'admin1' - } - }, - { - 'type': { - 'value': 'admin2' - } - } - ] + 'exists': { + 'field': 'popularity' + } }, 'functions': [{ 'field_value_factor': { @@ -75,6 +62,35 @@ module.exports = { 'weight': 1 }] } + },{ + 'function_score': { + 'query': { + 'match': { + 'phrase.default': { + 'query': 'test', + 'analyzer': 'peliasPhrase', + 'type': 'phrase', + 'slop': 2, + 'boost': 1 + } + } + }, + 'max_boost': 2000, + 'score_mode': 'first', + 'boost_mode': 'replace', + 'filter': { + 'exists': { + 'field': 'population' + } + }, + 'functions': [{ + 'field_value_factor': { + 'modifier': 'sqrt', + 'field': 'population' + }, + 'weight': 1 + }] + } }] } } diff --git a/test/unit/fixture/search_full_address.js b/test/unit/fixture/search_full_address.js index aff242b8..0abf05b1 100644 --- a/test/unit/fixture/search_full_address.js +++ b/test/unit/fixture/search_full_address.js @@ -30,35 +30,23 @@ 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': 10000, 'score_mode': 'first', 'boost_mode': 'replace', 'filter': { - 'or': [ - { - 'type': { - 'value': 'admin0' - } - }, - { - 'type': { - 'value': 'admin1' - } - }, - { - 'type': { - 'value': 'admin2' - } - } - ] + 'exists': { + 'field': 'popularity' + } }, 'functions': [{ 'field_value_factor': { @@ -68,6 +56,35 @@ module.exports = { 'weight': 1 }] } + },{ + 'function_score': { + 'query': { + 'match': { + 'phrase.default': { + 'query': '123 main st', + 'analyzer': 'peliasPhrase', + 'type': 'phrase', + 'slop': 2, + 'boost': 1 + } + } + }, + 'max_boost': 2000, + 'score_mode': 'first', + 'boost_mode': 'replace', + 'filter': { + 'exists': { + 'field': 'population' + } + }, + 'functions': [{ + 'field_value_factor': { + 'modifier': 'sqrt', + 'field': 'population' + }, + 'weight': 1 + }] + } },{ '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..738d1b83 100644 --- a/test/unit/fixture/search_linguistic_bbox.js +++ b/test/unit/fixture/search_linguistic_bbox.js @@ -23,39 +23,26 @@ 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': 10000, 'score_mode': 'first', 'boost_mode': 'replace', 'filter': { - 'or': [ - { - 'type': { - 'value': 'admin0' - } - }, - { - 'type': { - 'value': 'admin1' - } - }, - { - 'type': { - 'value': 'admin2' - } - } - ] + 'exists': { + 'field': 'popularity' + } }, 'functions': [{ 'field_value_factor': { @@ -65,6 +52,35 @@ module.exports = { 'weight': 1 }] } + },{ + 'function_score': { + 'query': { + 'match': { + 'phrase.default': { + 'query': 'test', + 'analyzer': 'peliasPhrase', + 'type': 'phrase', + 'slop': 2, + 'boost': 1 + } + } + }, + 'max_boost': 2000, + 'score_mode': 'first', + 'boost_mode': 'replace', + 'filter': { + 'exists': { + 'field': 'population' + } + }, + 'functions': [{ + 'field_value_factor': { + 'modifier': 'sqrt', + 'field': 'population' + }, + 'weight': 1 + }] + } }] } }, @@ -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..c20ddbf9 100644 --- a/test/unit/fixture/search_linguistic_focus.js +++ b/test/unit/fixture/search_linguistic_focus.js @@ -52,39 +52,26 @@ module.exports = { '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': 10000, 'score_mode': 'first', 'boost_mode': 'replace', 'filter': { - 'or': [ - { - 'type': { - 'value': 'admin0' - } - }, - { - 'type': { - 'value': 'admin1' - } - }, - { - 'type': { - 'value': 'admin2' - } - } - ] + 'exists': { + 'field': 'popularity' + } }, 'functions': [{ 'field_value_factor': { @@ -94,6 +81,35 @@ module.exports = { 'weight': 1 }] } + },{ + 'function_score': { + 'query': { + 'match': { + 'phrase.default': { + 'query': 'test', + 'analyzer': 'peliasPhrase', + 'type': 'phrase', + 'slop': 2, + 'boost': 1 + } + } + }, + 'max_boost': 2000, + 'score_mode': 'first', + 'boost_mode': 'replace', + 'filter': { + 'exists': { + 'field': 'population' + } + }, + 'functions': [{ + 'field_value_factor': { + 'modifier': 'sqrt', + 'field': 'population' + }, + 'weight': 1 + }] + } }] } } @@ -102,4 +118,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..92301fa6 100644 --- a/test/unit/fixture/search_linguistic_focus_bbox.js +++ b/test/unit/fixture/search_linguistic_focus_bbox.js @@ -52,39 +52,26 @@ module.exports = { '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': 10000, 'score_mode': 'first', 'boost_mode': 'replace', 'filter': { - 'or': [ - { - 'type': { - 'value': 'admin0' - } - }, - { - 'type': { - 'value': 'admin1' - } - }, - { - 'type': { - 'value': 'admin2' - } - } - ] + 'exists': { + 'field': 'popularity' + } }, 'functions': [{ 'field_value_factor': { @@ -94,6 +81,35 @@ module.exports = { 'weight': 1 }] } + },{ + 'function_score': { + 'query': { + 'match': { + 'phrase.default': { + 'query': 'test', + 'analyzer': 'peliasPhrase', + 'type': 'phrase', + 'slop': 2, + 'boost': 1 + } + } + }, + 'max_boost': 2000, + 'score_mode': 'first', + 'boost_mode': 'replace', + 'filter': { + 'exists': { + 'field': 'population' + } + }, + 'functions': [{ + 'field_value_factor': { + 'modifier': 'sqrt', + 'field': 'population' + }, + 'weight': 1 + }] + } }] } }, @@ -118,4 +134,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..85e6d40a 100644 --- a/test/unit/fixture/search_linguistic_focus_null_island.js +++ b/test/unit/fixture/search_linguistic_focus_null_island.js @@ -52,39 +52,26 @@ module.exports = { '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': 10000, 'score_mode': 'first', 'boost_mode': 'replace', 'filter': { - 'or': [ - { - 'type': { - 'value': 'admin0' - } - }, - { - 'type': { - 'value': 'admin1' - } - }, - { - 'type': { - 'value': 'admin2' - } - } - ] + 'exists': { + 'field': 'popularity' + } }, 'functions': [{ 'field_value_factor': { @@ -94,6 +81,35 @@ module.exports = { 'weight': 1 }] } + },{ + 'function_score': { + 'query': { + 'match': { + 'phrase.default': { + 'query': 'test', + 'analyzer': 'peliasPhrase', + 'type': 'phrase', + 'slop': 2, + 'boost': 1 + } + } + }, + 'max_boost': 2000, + 'score_mode': 'first', + 'boost_mode': 'replace', + 'filter': { + 'exists': { + 'field': 'population' + } + }, + 'functions': [{ + 'field_value_factor': { + 'modifier': 'sqrt', + 'field': 'population' + }, + 'weight': 1 + }] + } }] } } diff --git a/test/unit/fixture/search_linguistic_only.js b/test/unit/fixture/search_linguistic_only.js index ac059ef1..65db3fc8 100644 --- a/test/unit/fixture/search_linguistic_only.js +++ b/test/unit/fixture/search_linguistic_only.js @@ -23,39 +23,26 @@ 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': 10000, 'score_mode': 'first', 'boost_mode': 'replace', 'filter': { - 'or': [ - { - 'type': { - 'value': 'admin0' - } - }, - { - 'type': { - 'value': 'admin1' - } - }, - { - 'type': { - 'value': 'admin2' - } - } - ] + 'exists': { + 'field': 'popularity' + } }, 'functions': [{ 'field_value_factor': { @@ -65,6 +52,35 @@ module.exports = { 'weight': 1 }] } + },{ + 'function_score': { + 'query': { + 'match': { + 'phrase.default': { + 'query': 'test', + 'analyzer': 'peliasPhrase', + 'type': 'phrase', + 'slop': 2, + 'boost': 1 + } + } + }, + 'max_boost': 2000, + 'score_mode': 'first', + 'boost_mode': 'replace', + 'filter': { + 'exists': { + 'field': 'population' + } + }, + 'functions': [{ + 'field_value_factor': { + 'modifier': 'sqrt', + 'field': 'population' + }, + 'weight': 1 + }] + } }] } } @@ -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..d60ebf36 100644 --- a/test/unit/fixture/search_partial_address.js +++ b/test/unit/fixture/search_partial_address.js @@ -26,39 +26,26 @@ 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': 10000, 'score_mode': 'first', 'boost_mode': 'replace', 'filter': { - 'or': [ - { - 'type': { - 'value': 'admin0' - } - }, - { - 'type': { - 'value': 'admin1' - } - }, - { - 'type': { - 'value': 'admin2' - } - } - ] + 'exists': { + 'field': 'popularity' + } }, 'functions': [{ 'field_value_factor': { @@ -68,6 +55,35 @@ module.exports = { 'weight': 1 }] } + },{ + 'function_score': { + 'query': { + 'match': { + 'phrase.default': { + 'query': 'soho grand', + 'analyzer': 'peliasPhrase', + 'type': 'phrase', + 'slop': 2, + 'boost': 1 + } + } + }, + 'max_boost': 2000, + 'score_mode': 'first', + 'boost_mode': 'replace', + 'filter': { + 'exists': { + 'field': 'population' + } + }, + 'functions': [{ + 'field_value_factor': { + 'modifier': 'sqrt', + 'field': 'population' + }, + 'weight': 1 + }] + } },{ '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..17e32ab4 100644 --- a/test/unit/fixture/search_regions_address.js +++ b/test/unit/fixture/search_regions_address.js @@ -26,39 +26,26 @@ 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': 10000, 'score_mode': 'first', 'boost_mode': 'replace', 'filter': { - 'or': [ - { - 'type': { - 'value': 'admin0' - } - }, - { - 'type': { - 'value': 'admin1' - } - }, - { - 'type': { - 'value': 'admin2' - } - } - ] + 'exists': { + 'field': 'popularity' + } }, 'functions': [{ 'field_value_factor': { @@ -68,6 +55,35 @@ module.exports = { 'weight': 1 }] } + },{ + 'function_score': { + 'query': { + 'match': { + 'phrase.default': { + 'query': '1 water st', + 'analyzer': 'peliasPhrase', + 'type': 'phrase', + 'slop': 2, + 'boost': 1 + } + } + }, + 'max_boost': 2000, + 'score_mode': 'first', + 'boost_mode': 'replace', + 'filter': { + 'exists': { + 'field': 'population' + } + }, + 'functions': [{ + 'field_value_factor': { + 'modifier': 'sqrt', + 'field': 'population' + }, + 'weight': 1 + }] + } },{ 'match': { 'address.number': { @@ -148,4 +164,4 @@ module.exports = { 'size': 10, 'sort': [ '_score' ], 'track_scores': true -}; \ No newline at end of file +};