diff --git a/package.json b/package.json index d2787371f..2ddefefd4 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "pelias-microservice-wrapper": "^1.10.0", "pelias-model": "^9.0.0", "pelias-parser": "2.2.0", - "pelias-query": "^11.0.0", + "pelias-query": "github:pelias/query#additional-name-fields", "pelias-sorting": "^1.2.0", "predicates": "^2.0.0", "regenerate": "^1.4.0", diff --git a/query/search_pelias_parser.js b/query/search_pelias_parser.js index 65a836834..54a04e71b 100644 --- a/query/search_pelias_parser.js +++ b/query/search_pelias_parser.js @@ -5,7 +5,10 @@ const textParser = require('./text_parser_pelias'); const config = require('pelias-config').generate().api; var placeTypes = require('../helper/placeTypes'); -var views = { custom_boosts: require('./view/boost_sources_and_layers') }; +var views = { + custom_boosts: require('./view/boost_sources_and_layers'), + query_multi_match: require('./view/query_multi_match') +}; // region_a is also an admin field which can be identified by // the pelias_parser. this functionality was inherited from the @@ -18,10 +21,10 @@ var adminFields = placeTypes.concat(['region_a']); var query = new peliasQuery.layout.FilteredBooleanQuery(); // mandatory matches -query.score( peliasQuery.view.leaf.match('main'), 'must' ); +query.score( views.query_multi_match('match', 'main'), 'must' ); // scoring boost -const phrase_view = peliasQuery.view.leaf.match_phrase('main'); +const phrase_view = views.query_multi_match('match_phrase', 'main', 'phrase'); query.score( phrase_view ); query.score( peliasQuery.view.focus( peliasQuery.view.leaf.match_all ) ); diff --git a/query/view/helper.js b/query/view/helper.js index df41110c8..3a7e10dfa 100644 --- a/query/view/helper.js +++ b/query/view/helper.js @@ -1,5 +1,12 @@ -function toMultiFields(baseField, suffix) { - return [baseField, toSingleField(baseField, suffix)]; +const _ = require('lodash'); + +function toMultiFields(baseField, ...suffix) { + return [ + baseField, + ...suffix + .filter(e => _.isString(e) && !_.isEmpty(e)) + .map(suffix => toSingleField(baseField, suffix)) + ]; } function toSingleField(baseField, suffix) { @@ -9,4 +16,12 @@ function toSingleField(baseField, suffix) { return parts.join('.'); } -module.exports = { toMultiFields, toSingleField }; \ No newline at end of file +function toMultiFieldsWithWildcards(baseField, ...suffix) { + const result = []; + toMultiFields(baseField, ...suffix).forEach(field => { + result.push(field, `${field}_*`); + }); + return result; +} + +module.exports = { toMultiFields, toSingleField, toMultiFieldsWithWildcards }; diff --git a/query/view/ngrams_strict.js b/query/view/ngrams_strict.js index 06400e559..efb6bffc2 100644 --- a/query/view/ngrams_strict.js +++ b/query/view/ngrams_strict.js @@ -1,5 +1,5 @@ const peliasQuery = require('pelias-query'); -const toMultiFields = require('./helper').toMultiFields; +const toMultiFieldsWithWildcards = require('./helper').toMultiFieldsWithWildcards; /** Ngrams view with the additional properties to enable: @@ -16,7 +16,10 @@ module.exports = function( vs ){ } vs.var('multi_match:ngrams_strict:input', vs.var('input:name').get()); - vs.var('multi_match:ngrams_strict:fields', toMultiFields(vs.var('ngram:field').get(), vs.var('lang').get())); + vs.var('multi_match:ngrams_strict:fields', toMultiFieldsWithWildcards( + vs.var('ngram:field').get(), + vs.var('lang').get(), + )); vs.var('multi_match:ngrams_strict:analyzer', vs.var('ngram:analyzer').get()); vs.var('multi_match:ngrams_strict:slop', vs.var('phrase:slop').get()); diff --git a/query/view/phrase_first_tokens_only.js b/query/view/phrase_first_tokens_only.js index f68f15aaa..92a5e63ca 100644 --- a/query/view/phrase_first_tokens_only.js +++ b/query/view/phrase_first_tokens_only.js @@ -1,5 +1,5 @@ const peliasQuery = require('pelias-query'); -const toMultiFields = require('./helper').toMultiFields; +const toMultiFieldsWithWildcards = require('./helper').toMultiFieldsWithWildcards; /** Phrase view which trims the 'input:name' and uses ALL BUT the last token. @@ -18,7 +18,10 @@ module.exports = function( vs ){ // set the 'input' variable to all but the last token vs.var(`multi_match:${view_name}:input`).set( tokens.join(' ') ); - vs.var(`multi_match:${view_name}:fields`).set(toMultiFields(vs.var('phrase:field').get(), vs.var('lang').get())); + vs.var(`multi_match:${view_name}:fields`, toMultiFieldsWithWildcards( + vs.var('phrase:field').get(), + vs.var('lang').get(), + )); vs.var(`multi_match:${view_name}:analyzer`).set(vs.var('phrase:analyzer').get()); vs.var(`multi_match:${view_name}:boost`).set(vs.var('phrase:boost').get()); diff --git a/query/view/query_multi_match.js b/query/view/query_multi_match.js new file mode 100644 index 000000000..d3042a95b --- /dev/null +++ b/query/view/query_multi_match.js @@ -0,0 +1,52 @@ +const _ = require('lodash'); +const toMultiFieldsWithWildcards = require('./helper').toMultiFieldsWithWildcards; + +const optional_params = [ + 'boost', + 'slop', + 'operator', + 'analyzer', + 'cutoff_frequency', + 'fuzziness', + 'max_expansions', + 'prefix_length', + 'fuzzy_transpositions', + 'minimum_should_match', + 'zero_terms_query' +]; + +module.exports = (namespace, prefix, type) => { + return (vs) => { + const input_variable = `${namespace}:${prefix}:input`; + const field_variable = `${namespace}:${prefix}:field`; + + if (!vs.isset(input_variable) || !vs.isset(field_variable)) { + return null; + } + + const query = { + multi_match: { + query: vs.var(input_variable), + fields: toMultiFieldsWithWildcards( + vs.var(field_variable).get(), + vs.var('lang').get(), + ) + } + }; + + // optional 'type' + if (_.isString(type)) { + query.multi_match.type = type; + } + + // other optional params + optional_params.forEach((param) => { + const variable_name = `${namespace}:${prefix}:${param}`; + if (vs.isset(variable_name)) { + query.multi_match[param] = vs.var(variable_name); + } + }); + + return query; + }; +}; diff --git a/test/unit/fixture/autocomplete_boundary_country.js b/test/unit/fixture/autocomplete_boundary_country.js index 64a70552c..72e376c85 100644 --- a/test/unit/fixture/autocomplete_boundary_country.js +++ b/test/unit/fixture/autocomplete_boundary_country.js @@ -5,7 +5,12 @@ module.exports = { 'constant_score': { 'filter': { 'multi_match': { - 'fields': ['name.default', 'name.en'], + 'fields': [ + 'name.default', + 'name.default_*', + 'name.en', + 'name.en_*' + ], 'analyzer': 'peliasQuery', 'query': 'test', 'boost': 100, diff --git a/test/unit/fixture/autocomplete_boundary_gid.js b/test/unit/fixture/autocomplete_boundary_gid.js index 5ccb058ca..c8e72a0f1 100644 --- a/test/unit/fixture/autocomplete_boundary_gid.js +++ b/test/unit/fixture/autocomplete_boundary_gid.js @@ -5,7 +5,12 @@ module.exports = { 'constant_score': { 'filter': { 'multi_match': { - 'fields': ['name.default', 'name.en'], + 'fields': [ + 'name.default', + 'name.default_*', + 'name.en', + 'name.en_*' + ], 'analyzer': 'peliasQuery', 'query': 'test', 'boost': 100, diff --git a/test/unit/fixture/autocomplete_custom_boosts.json b/test/unit/fixture/autocomplete_custom_boosts.json index 556f1452b..19be238f8 100644 --- a/test/unit/fixture/autocomplete_custom_boosts.json +++ b/test/unit/fixture/autocomplete_custom_boosts.json @@ -6,7 +6,12 @@ "must": [ { "multi_match": { - "fields": ["phrase.default", "phrase.en"], + "fields": [ + "phrase.default", + "phrase.default_*", + "phrase.en", + "phrase.en_*" + ], "analyzer": "peliasQuery", "query": "foo", "boost": 1, diff --git a/test/unit/fixture/autocomplete_linguistic_bbox_san_francisco.js b/test/unit/fixture/autocomplete_linguistic_bbox_san_francisco.js index 787450f4a..b4dc4ccf1 100644 --- a/test/unit/fixture/autocomplete_linguistic_bbox_san_francisco.js +++ b/test/unit/fixture/autocomplete_linguistic_bbox_san_francisco.js @@ -5,7 +5,12 @@ module.exports = { 'constant_score': { 'filter': { 'multi_match': { - 'fields': ['name.default', 'name.en'], + 'fields': [ + 'name.default', + 'name.default_*', + 'name.en', + 'name.en_*' + ], 'analyzer': 'peliasQuery', 'query': 'test', 'boost': 100, diff --git a/test/unit/fixture/autocomplete_linguistic_circle_san_francisco.js b/test/unit/fixture/autocomplete_linguistic_circle_san_francisco.js index fdeb8757f..1323017b9 100644 --- a/test/unit/fixture/autocomplete_linguistic_circle_san_francisco.js +++ b/test/unit/fixture/autocomplete_linguistic_circle_san_francisco.js @@ -6,7 +6,12 @@ module.exports = { 'constant_score': { 'filter': { 'multi_match': { - 'fields': ['name.default', 'name.en'], + 'fields': [ + 'name.default', + 'name.default_*', + 'name.en', + 'name.en_*' + ], 'analyzer': 'peliasQuery', 'query': 'test', 'boost': 100, diff --git a/test/unit/fixture/autocomplete_linguistic_final_token.js b/test/unit/fixture/autocomplete_linguistic_final_token.js index 43ffa2783..1ac4bd862 100644 --- a/test/unit/fixture/autocomplete_linguistic_final_token.js +++ b/test/unit/fixture/autocomplete_linguistic_final_token.js @@ -3,7 +3,12 @@ module.exports = { 'bool': { 'must': [{ 'multi_match': { - 'fields': ['phrase.default', 'phrase.en'], + 'fields': [ + 'phrase.default', + 'phrase.default_*', + 'phrase.en', + 'phrase.en_*' + ], 'analyzer': 'peliasQuery', 'query': 'one', 'boost': 1, diff --git a/test/unit/fixture/autocomplete_linguistic_focus.js b/test/unit/fixture/autocomplete_linguistic_focus.js index bfde87014..f1981f912 100644 --- a/test/unit/fixture/autocomplete_linguistic_focus.js +++ b/test/unit/fixture/autocomplete_linguistic_focus.js @@ -5,7 +5,12 @@ module.exports = { 'constant_score': { 'filter': { 'multi_match': { - 'fields': ['name.default', 'name.en'], + 'fields': [ + 'name.default', + 'name.default_*', + 'name.en', + 'name.en_*' + ], 'analyzer': 'peliasQuery', 'query': 'test', 'boost': 100, diff --git a/test/unit/fixture/autocomplete_linguistic_focus_null_island.js b/test/unit/fixture/autocomplete_linguistic_focus_null_island.js index 5ceed3548..349cf5c5a 100644 --- a/test/unit/fixture/autocomplete_linguistic_focus_null_island.js +++ b/test/unit/fixture/autocomplete_linguistic_focus_null_island.js @@ -5,7 +5,12 @@ module.exports = { 'constant_score': { 'filter': { 'multi_match': { - 'fields': ['name.default', 'name.en'], + 'fields': [ + 'name.default', + 'name.default_*', + 'name.en', + 'name.en_*' + ], 'analyzer': 'peliasQuery', 'query': 'test', 'boost': 100, diff --git a/test/unit/fixture/autocomplete_linguistic_multiple_tokens.js b/test/unit/fixture/autocomplete_linguistic_multiple_tokens.js index 157c224d1..77a4e123e 100644 --- a/test/unit/fixture/autocomplete_linguistic_multiple_tokens.js +++ b/test/unit/fixture/autocomplete_linguistic_multiple_tokens.js @@ -3,7 +3,12 @@ module.exports = { 'bool': { 'must': [{ 'multi_match': { - 'fields': ['phrase.default', 'phrase.en'], + 'fields': [ + 'phrase.default', + 'phrase.default_*', + 'phrase.en', + 'phrase.en_*' + ], 'analyzer': 'peliasQuery', 'query': 'one two', 'boost': 1, diff --git a/test/unit/fixture/autocomplete_linguistic_multiple_tokens_complete_numeric.js b/test/unit/fixture/autocomplete_linguistic_multiple_tokens_complete_numeric.js index 3bb89a8fa..710f994e9 100644 --- a/test/unit/fixture/autocomplete_linguistic_multiple_tokens_complete_numeric.js +++ b/test/unit/fixture/autocomplete_linguistic_multiple_tokens_complete_numeric.js @@ -3,7 +3,12 @@ module.exports = { 'bool': { 'must': [{ 'multi_match': { - 'fields': ['phrase.default', 'phrase.en'], + 'fields': [ + 'phrase.default', + 'phrase.default_*', + 'phrase.en', + 'phrase.en_*' + ], 'analyzer': 'peliasQuery', 'type': 'phrase', 'slop': 3, @@ -15,7 +20,12 @@ module.exports = { 'constant_score': { 'filter': { 'multi_match': { - 'fields': ['name.default', 'name.en'], + 'fields': [ + 'name.default', + 'name.default_*', + 'name.en', + 'name.en_*' + ], 'analyzer': 'peliasQuery', 'query': 'three', 'boost': 100, diff --git a/test/unit/fixture/autocomplete_linguistic_one_char_token.js b/test/unit/fixture/autocomplete_linguistic_one_char_token.js index 7a4286910..a6d1a83dd 100644 --- a/test/unit/fixture/autocomplete_linguistic_one_char_token.js +++ b/test/unit/fixture/autocomplete_linguistic_one_char_token.js @@ -5,7 +5,12 @@ module.exports = { 'constant_score': { 'filter': { 'multi_match': { - 'fields': ['name.default', 'name.en'], + 'fields': [ + 'name.default', + 'name.default_*', + 'name.en', + 'name.en_*' + ], 'analyzer': 'peliasQuery', 'query': 't', 'boost': 100, diff --git a/test/unit/fixture/autocomplete_linguistic_only.js b/test/unit/fixture/autocomplete_linguistic_only.js index b8c50a99d..6f7bee434 100644 --- a/test/unit/fixture/autocomplete_linguistic_only.js +++ b/test/unit/fixture/autocomplete_linguistic_only.js @@ -5,7 +5,12 @@ module.exports = { 'constant_score': { 'filter': { 'multi_match': { - 'fields': ['name.default', 'name.en'], + 'fields': [ + 'name.default', + 'name.default_*', + 'name.en', + 'name.en_*' + ], 'analyzer': 'peliasQuery', 'query': 'test', 'boost': 100, diff --git a/test/unit/fixture/autocomplete_linguistic_three_char_token.js b/test/unit/fixture/autocomplete_linguistic_three_char_token.js index 79b2dea27..3de458b76 100644 --- a/test/unit/fixture/autocomplete_linguistic_three_char_token.js +++ b/test/unit/fixture/autocomplete_linguistic_three_char_token.js @@ -5,7 +5,12 @@ module.exports = { 'constant_score': { 'filter': { 'multi_match': { - 'fields': ['name.default', 'name.en'], + 'fields': [ + 'name.default', + 'name.default_*', + 'name.en', + 'name.en_*' + ], 'analyzer': 'peliasQuery', 'query': 'tes', 'boost': 100, diff --git a/test/unit/fixture/autocomplete_linguistic_two_char_token.js b/test/unit/fixture/autocomplete_linguistic_two_char_token.js index b95dafacd..92f081b86 100644 --- a/test/unit/fixture/autocomplete_linguistic_two_char_token.js +++ b/test/unit/fixture/autocomplete_linguistic_two_char_token.js @@ -5,7 +5,12 @@ module.exports = { 'constant_score': { 'filter': { 'multi_match': { - 'fields': ['name.default', 'name.en'], + 'fields': [ + 'name.default', + 'name.default_*', + 'name.en', + 'name.en_*' + ], 'analyzer': 'peliasQuery', 'query': 'te', 'boost': 100, diff --git a/test/unit/fixture/autocomplete_linguistic_with_admin.js b/test/unit/fixture/autocomplete_linguistic_with_admin.js index e162915fb..0eb3f8a62 100644 --- a/test/unit/fixture/autocomplete_linguistic_with_admin.js +++ b/test/unit/fixture/autocomplete_linguistic_with_admin.js @@ -4,7 +4,12 @@ module.exports = { 'must': [ { 'multi_match': { - 'fields': ['phrase.default', 'phrase.en'], + 'fields': [ + 'phrase.default', + 'phrase.default_*', + 'phrase.en', + 'phrase.en_*' + ], 'analyzer': 'peliasQuery', 'type': 'phrase', 'slop': 3, diff --git a/test/unit/fixture/autocomplete_single_character_street.js b/test/unit/fixture/autocomplete_single_character_street.js index 1c7e421e2..caa090099 100644 --- a/test/unit/fixture/autocomplete_single_character_street.js +++ b/test/unit/fixture/autocomplete_single_character_street.js @@ -3,7 +3,12 @@ module.exports = { 'bool': { 'must': [{ 'multi_match': { - 'fields': ['phrase.default', 'phrase.en'], + 'fields': [ + 'phrase.default', + 'phrase.default_*', + 'phrase.en', + 'phrase.en_*' + ], 'analyzer': 'peliasQuery', 'query': 'k road', 'boost': 1, diff --git a/test/unit/fixture/autocomplete_with_category_filtering.js b/test/unit/fixture/autocomplete_with_category_filtering.js index 5ee33d85a..167fdae3f 100644 --- a/test/unit/fixture/autocomplete_with_category_filtering.js +++ b/test/unit/fixture/autocomplete_with_category_filtering.js @@ -5,7 +5,12 @@ module.exports = { 'constant_score': { 'filter': { 'multi_match': { - 'fields': ['name.default', 'name.en'], + 'fields': [ + 'name.default', + 'name.default_*', + 'name.en', + 'name.en_*' + ], 'analyzer': 'peliasQuery', 'query': 'test', 'boost': 100, diff --git a/test/unit/fixture/autocomplete_with_layer_filtering.js b/test/unit/fixture/autocomplete_with_layer_filtering.js index 916e5925a..2de3b0521 100644 --- a/test/unit/fixture/autocomplete_with_layer_filtering.js +++ b/test/unit/fixture/autocomplete_with_layer_filtering.js @@ -5,7 +5,12 @@ module.exports = { 'constant_score': { 'filter': { 'multi_match': { - 'fields': ['name.default', 'name.en'], + 'fields': [ + 'name.default', + 'name.default_*', + 'name.en', + 'name.en_*' + ], 'analyzer': 'peliasQuery', 'query': 'test', 'boost': 100, diff --git a/test/unit/fixture/autocomplete_with_source_filtering.js b/test/unit/fixture/autocomplete_with_source_filtering.js index af3eea8c2..e4ec04e84 100644 --- a/test/unit/fixture/autocomplete_with_source_filtering.js +++ b/test/unit/fixture/autocomplete_with_source_filtering.js @@ -5,7 +5,12 @@ module.exports = { 'constant_score': { 'filter': { 'multi_match': { - 'fields': ['name.default', 'name.en'], + 'fields': [ + 'name.default', + 'name.default_*', + 'name.en', + 'name.en_*' + ], 'analyzer': 'peliasQuery', 'query': 'test', 'boost': 100, diff --git a/test/unit/fixture/search_fallback.js b/test/unit/fixture/search_fallback.js index 11943e72b..f42f4869b 100644 --- a/test/unit/fixture/search_fallback.js +++ b/test/unit/fixture/search_fallback.js @@ -14,7 +14,8 @@ module.exports = { 'query': 'query value', 'type': 'phrase', 'fields': [ - 'phrase.default' + 'phrase.default', + 'phrase.default_*' ] } }, diff --git a/test/unit/fixture/search_pelias_parser_boundary_country.js b/test/unit/fixture/search_pelias_parser_boundary_country.js index 7e3ecd8f2..98579d8f2 100644 --- a/test/unit/fixture/search_pelias_parser_boundary_country.js +++ b/test/unit/fixture/search_pelias_parser_boundary_country.js @@ -3,23 +3,28 @@ module.exports = { 'bool': { 'must': [ { - 'match': { - 'phrase.default': { - 'query': 'test', - 'minimum_should_match': '1<-1 3<-25%', - 'analyzer': 'peliasQuery' - } + 'multi_match': { + 'query': 'test', + 'minimum_should_match': '1<-1 3<-25%', + 'analyzer': 'peliasQuery', + 'fields': [ + 'phrase.default', + 'phrase.default_*' + ] } } ], 'should': [{ - 'match_phrase': { - 'phrase.default': { - 'query': 'test', - 'analyzer': 'peliasPhrase', - 'boost': 1, - 'slop': 2 - } + 'multi_match': { + 'query': 'test', + 'type': 'phrase', + 'analyzer': 'peliasPhrase', + 'fields': [ + 'phrase.default', + 'phrase.default_*' + ], + 'slop': 2, + 'boost': 1 } },{ 'function_score': { diff --git a/test/unit/fixture/search_pelias_parser_boundary_gid.js b/test/unit/fixture/search_pelias_parser_boundary_gid.js index 5cd2d37dd..d67716dd0 100644 --- a/test/unit/fixture/search_pelias_parser_boundary_gid.js +++ b/test/unit/fixture/search_pelias_parser_boundary_gid.js @@ -3,23 +3,28 @@ module.exports = { 'bool': { 'must': [ { - 'match': { - 'phrase.default': { - 'query': 'test', - 'minimum_should_match': '1<-1 3<-25%', - 'analyzer': 'peliasQuery' - } + 'multi_match': { + 'query': 'test', + 'minimum_should_match': '1<-1 3<-25%', + 'analyzer': 'peliasQuery', + 'fields': [ + 'phrase.default', + 'phrase.default_*' + ] } } ], 'should': [{ - 'match_phrase': { - 'phrase.default': { - 'query': 'test', - 'analyzer': 'peliasPhrase', - 'boost': 1, - 'slop': 2 - } + 'multi_match': { + 'query': 'test', + 'type': 'phrase', + 'analyzer': 'peliasPhrase', + 'fields': [ + 'phrase.default', + 'phrase.default_*' + ], + 'slop': 2, + 'boost': 1 } },{ 'function_score': { diff --git a/test/unit/fixture/search_pelias_parser_full_address.js b/test/unit/fixture/search_pelias_parser_full_address.js index c7711bc11..7491132ae 100644 --- a/test/unit/fixture/search_pelias_parser_full_address.js +++ b/test/unit/fixture/search_pelias_parser_full_address.js @@ -4,22 +4,27 @@ module.exports = { 'query': { 'bool': { 'must': [{ - 'match': { - 'phrase.default': { - 'query': '123 main st', - 'minimum_should_match': '1<-1 3<-25%', - 'analyzer': 'peliasQuery', - } + 'multi_match': { + 'query': '123 main st', + 'minimum_should_match': '1<-1 3<-25%', + 'analyzer': 'peliasQuery', + 'fields': [ + 'phrase.default', + 'phrase.default_*' + ] } }], 'should': [{ - 'match_phrase': { - 'phrase.default': { - 'query': '123 main st', - 'analyzer': 'peliasPhrase', - 'slop': 2, - 'boost': 1 - } + 'multi_match': { + 'query': '123 main st', + 'type': 'phrase', + 'analyzer': 'peliasPhrase', + 'fields': [ + 'phrase.default', + 'phrase.default_*' + ], + 'slop': 2, + 'boost': 1 } }, { diff --git a/test/unit/fixture/search_pelias_parser_linguistic_bbox.js b/test/unit/fixture/search_pelias_parser_linguistic_bbox.js index 39feba566..00c3805d1 100644 --- a/test/unit/fixture/search_pelias_parser_linguistic_bbox.js +++ b/test/unit/fixture/search_pelias_parser_linguistic_bbox.js @@ -2,22 +2,27 @@ module.exports = { 'query': { 'bool': { 'must': [{ - 'match': { - 'phrase.default': { - 'query': 'test', - 'minimum_should_match': '1<-1 3<-25%', - 'analyzer': 'peliasQuery' - } + 'multi_match': { + 'query': 'test', + 'minimum_should_match': '1<-1 3<-25%', + 'analyzer': 'peliasQuery', + 'fields': [ + 'phrase.default', + 'phrase.default_*' + ] } }], 'should': [{ - 'match_phrase': { - 'phrase.default': { - 'query': 'test', - 'analyzer': 'peliasPhrase', - 'boost': 1, - 'slop': 2 - } + 'multi_match': { + 'query': 'test', + 'type': 'phrase', + 'analyzer': 'peliasPhrase', + 'fields': [ + 'phrase.default', + 'phrase.default_*' + ], + 'slop': 2, + 'boost': 1 } },{ 'function_score': { diff --git a/test/unit/fixture/search_pelias_parser_linguistic_focus.js b/test/unit/fixture/search_pelias_parser_linguistic_focus.js index 8b192309c..13fbbf2d6 100644 --- a/test/unit/fixture/search_pelias_parser_linguistic_focus.js +++ b/test/unit/fixture/search_pelias_parser_linguistic_focus.js @@ -2,22 +2,27 @@ module.exports = { 'query': { 'bool': { 'must': [{ - 'match': { - 'phrase.default': { - 'query': 'test', - 'minimum_should_match': '1<-1 3<-25%', - 'analyzer': 'peliasQuery' - } + 'multi_match': { + 'query': 'test', + 'minimum_should_match': '1<-1 3<-25%', + 'analyzer': 'peliasQuery', + 'fields': [ + 'phrase.default', + 'phrase.default_*' + ] } }], 'should': [{ - 'match_phrase': { - 'phrase.default': { - 'query': 'test', - 'analyzer': 'peliasPhrase', - 'boost': 1, - 'slop': 2 - } + 'multi_match': { + 'query': 'test', + 'type': 'phrase', + 'analyzer': 'peliasPhrase', + 'fields': [ + 'phrase.default', + 'phrase.default_*' + ], + 'slop': 2, + 'boost': 1 } }, { 'function_score': { diff --git a/test/unit/fixture/search_pelias_parser_linguistic_focus_bbox.js b/test/unit/fixture/search_pelias_parser_linguistic_focus_bbox.js index c4ecb50a3..a5af3e916 100644 --- a/test/unit/fixture/search_pelias_parser_linguistic_focus_bbox.js +++ b/test/unit/fixture/search_pelias_parser_linguistic_focus_bbox.js @@ -2,22 +2,27 @@ module.exports = { 'query': { 'bool': { 'must': [{ - 'match': { - 'phrase.default': { - 'query': 'test', - 'minimum_should_match': '1<-1 3<-25%', - 'analyzer': 'peliasQuery' - } + 'multi_match': { + 'query': 'test', + 'minimum_should_match': '1<-1 3<-25%', + 'analyzer': 'peliasQuery', + 'fields': [ + 'phrase.default', + 'phrase.default_*' + ] } }], 'should': [{ - 'match_phrase': { - 'phrase.default': { - 'query': 'test', - 'analyzer': 'peliasPhrase', - 'boost': 1, - 'slop': 2 - } + 'multi_match': { + 'query': 'test', + 'type': 'phrase', + 'analyzer': 'peliasPhrase', + 'fields': [ + 'phrase.default', + 'phrase.default_*' + ], + 'slop': 2, + 'boost': 1 } }, { 'function_score': { diff --git a/test/unit/fixture/search_pelias_parser_linguistic_focus_null_island.js b/test/unit/fixture/search_pelias_parser_linguistic_focus_null_island.js index 28b00a673..bc2ab0ac1 100644 --- a/test/unit/fixture/search_pelias_parser_linguistic_focus_null_island.js +++ b/test/unit/fixture/search_pelias_parser_linguistic_focus_null_island.js @@ -2,22 +2,27 @@ module.exports = { 'query': { 'bool': { 'must': [{ - 'match': { - 'phrase.default': { - 'query': 'test', - 'minimum_should_match': '1<-1 3<-25%', - 'analyzer': 'peliasQuery' - } + 'multi_match': { + 'query': 'test', + 'minimum_should_match': '1<-1 3<-25%', + 'analyzer': 'peliasQuery', + 'fields': [ + 'phrase.default', + 'phrase.default_*' + ] } }], 'should': [{ - 'match_phrase': { - 'phrase.default': { - 'query': 'test', - 'analyzer': 'peliasPhrase', - 'boost': 1, - 'slop': 2 - } + 'multi_match': { + 'query': 'test', + 'type': 'phrase', + 'analyzer': 'peliasPhrase', + 'fields': [ + 'phrase.default', + 'phrase.default_*' + ], + 'slop': 2, + 'boost': 1 } }, { 'function_score': { diff --git a/test/unit/fixture/search_pelias_parser_linguistic_only.js b/test/unit/fixture/search_pelias_parser_linguistic_only.js index ca65cf263..9165eee66 100644 --- a/test/unit/fixture/search_pelias_parser_linguistic_only.js +++ b/test/unit/fixture/search_pelias_parser_linguistic_only.js @@ -2,22 +2,27 @@ module.exports = { 'query': { 'bool': { 'must': [{ - 'match': { - 'phrase.default': { - 'query': 'test', - 'minimum_should_match': '1<-1 3<-25%', - 'analyzer': 'peliasQuery' - } + 'multi_match': { + 'query': 'test', + 'minimum_should_match': '1<-1 3<-25%', + 'analyzer': 'peliasQuery', + 'fields': [ + 'phrase.default', + 'phrase.default_*' + ] } }], 'should': [{ - 'match_phrase': { - 'phrase.default': { - 'query': 'test', - 'analyzer': 'peliasPhrase', - 'boost': 1, - 'slop': 2 - } + 'multi_match': { + 'query': 'test', + 'type': 'phrase', + 'analyzer': 'peliasPhrase', + 'fields': [ + 'phrase.default', + 'phrase.default_*' + ], + 'slop': 2, + 'boost': 1 } },{ 'function_score': { diff --git a/test/unit/fixture/search_pelias_parser_partial_address.js b/test/unit/fixture/search_pelias_parser_partial_address.js index 08addbb2e..c1a7ef649 100644 --- a/test/unit/fixture/search_pelias_parser_partial_address.js +++ b/test/unit/fixture/search_pelias_parser_partial_address.js @@ -4,22 +4,27 @@ module.exports = { 'query': { 'bool': { 'must': [{ - 'match': { - 'phrase.default': { - 'query': 'soho grand', - 'minimum_should_match': '1<-1 3<-25%', - 'analyzer': 'peliasQuery', - } + 'multi_match': { + 'query': 'soho grand', + 'minimum_should_match': '1<-1 3<-25%', + 'analyzer': 'peliasQuery', + 'fields': [ + 'phrase.default', + 'phrase.default_*' + ] } }], 'should': [{ - 'match_phrase': { - 'phrase.default': { - 'query': 'soho grand', - 'analyzer': 'peliasPhrase', - 'slop': 2, - 'boost': 1 - } + 'multi_match': { + 'query': 'soho grand', + 'type': 'phrase', + 'analyzer': 'peliasPhrase', + 'fields': [ + 'phrase.default', + 'phrase.default_*' + ], + 'slop': 2, + 'boost': 1 } },{ 'function_score': { diff --git a/test/unit/fixture/search_pelias_parser_regions_address.js b/test/unit/fixture/search_pelias_parser_regions_address.js index 0228a59ed..a44dfaaed 100644 --- a/test/unit/fixture/search_pelias_parser_regions_address.js +++ b/test/unit/fixture/search_pelias_parser_regions_address.js @@ -4,22 +4,27 @@ module.exports = { 'query': { 'bool': { 'must': [{ - 'match': { - 'phrase.default': { - 'query': '1 water st', - 'minimum_should_match': '1<-1 3<-25%', - 'analyzer': 'peliasQuery', - } + 'multi_match': { + 'query': '1 water st', + 'minimum_should_match': '1<-1 3<-25%', + 'analyzer': 'peliasQuery', + 'fields': [ + 'phrase.default', + 'phrase.default_*' + ] } }], 'should': [{ - 'match_phrase': { - 'phrase.default': { - 'query': '1 water st', - 'analyzer': 'peliasPhrase', - 'slop': 2, - 'boost': 1 - } + 'multi_match': { + 'query': '1 water st', + 'type': 'phrase', + 'analyzer': 'peliasPhrase', + 'fields': [ + 'phrase.default', + 'phrase.default_*' + ], + 'slop': 2, + 'boost': 1 } },{ 'function_score': { diff --git a/test/unit/fixture/search_pelias_parser_with_category_filtering.js b/test/unit/fixture/search_pelias_parser_with_category_filtering.js index 9aa4f4c42..322e37eaf 100644 --- a/test/unit/fixture/search_pelias_parser_with_category_filtering.js +++ b/test/unit/fixture/search_pelias_parser_with_category_filtering.js @@ -2,22 +2,27 @@ module.exports = { 'query': { 'bool': { 'must': [{ - 'match': { - 'phrase.default': { - 'query': 'test', - 'minimum_should_match': '1<-1 3<-25%', - 'analyzer': 'peliasQuery' - } + 'multi_match': { + 'query': 'test', + 'minimum_should_match': '1<-1 3<-25%', + 'analyzer': 'peliasQuery', + 'fields': [ + 'phrase.default', + 'phrase.default_*' + ] } }], 'should': [{ - 'match_phrase': { - 'phrase.default': { - 'query': 'test', - 'analyzer': 'peliasPhrase', - 'boost': 1, - 'slop': 2 - } + 'multi_match': { + 'query': 'test', + 'type': 'phrase', + 'analyzer': 'peliasPhrase', + 'fields': [ + 'phrase.default', + 'phrase.default_*' + ], + 'slop': 2, + 'boost': 1 } }, { 'function_score': { diff --git a/test/unit/fixture/search_pelias_parser_with_source_filtering.js b/test/unit/fixture/search_pelias_parser_with_source_filtering.js index 4186b19d5..09e82689f 100644 --- a/test/unit/fixture/search_pelias_parser_with_source_filtering.js +++ b/test/unit/fixture/search_pelias_parser_with_source_filtering.js @@ -2,22 +2,27 @@ module.exports = { 'query': { 'bool': { 'must': [{ - 'match': { - 'phrase.default': { - 'query': 'test', - 'minimum_should_match': '1<-1 3<-25%', - 'analyzer': 'peliasQuery' - } + 'multi_match': { + 'query': 'test', + 'minimum_should_match': '1<-1 3<-25%', + 'analyzer': 'peliasQuery', + 'fields': [ + 'phrase.default', + 'phrase.default_*' + ] } }], 'should': [{ - 'match_phrase': { - 'phrase.default': { - 'query': 'test', - 'analyzer': 'peliasPhrase', - 'boost': 1, - 'slop': 2 - } + 'multi_match': { + 'query': 'test', + 'type': 'phrase', + 'analyzer': 'peliasPhrase', + 'fields': [ + 'phrase.default', + 'phrase.default_*' + ], + 'slop': 2, + 'boost': 1 } },{ 'function_score': { diff --git a/test/unit/fixture/search_with_custom_boosts.json b/test/unit/fixture/search_with_custom_boosts.json index 924fda28a..18ba08ee2 100644 --- a/test/unit/fixture/search_with_custom_boosts.json +++ b/test/unit/fixture/search_with_custom_boosts.json @@ -4,22 +4,27 @@ "query": { "bool": { "must": [{ - "match": { - "phrase.default": { - "query": "test", - "minimum_should_match": "1<-1 3<-25%", - "analyzer": "peliasQuery" - } + "multi_match": { + "query": "test", + "minimum_should_match": "1<-1 3<-25%", + "analyzer": "peliasQuery", + "fields": [ + "phrase.default", + "phrase.default_*" + ] } }], "should": [{ - "match_phrase": { - "phrase.default": { - "query": "test", - "analyzer": "peliasPhrase", - "boost": 1, - "slop": 2 - } + "multi_match": { + "query": "test", + "type": "phrase", + "analyzer": "peliasPhrase", + "fields": [ + "phrase.default", + "phrase.default_*" + ], + "boost": 1, + "slop": 2 } },{ "function_score": { diff --git a/test/unit/query/search.js b/test/unit/query/search.js index 5dac3bd93..8e8ad12a1 100644 --- a/test/unit/query/search.js +++ b/test/unit/query/search.js @@ -201,7 +201,7 @@ module.exports.tests.query = function(test, common) { var expected = require('../fixture/search_boundary_country_multi'); t.deepEqual(compiled.type, 'search_fallback', 'query type set'); - t.deepEqual(compiled.body, expected, 'search: valid multi boundary.country query'); + t.deepEqual(compiled.body, expected, 'search: valid multi boundary.country multi query'); t.end(); }); diff --git a/test/unit/query/search_pelias_parser.js b/test/unit/query/search_pelias_parser.js index 7c2eba0c9..c33da73f6 100644 --- a/test/unit/query/search_pelias_parser.js +++ b/test/unit/query/search_pelias_parser.js @@ -227,7 +227,7 @@ module.exports.tests.query = function(test, common) { module.exports.all = function (tape, common) { function test(name, testFunction) { - return tape('search query ' + name, testFunction); + return tape('search pelias parser ' + name, testFunction); } for( var testCase in module.exports.tests ){