From 279ca1c5aeeb0ffd34ee72bc1d579a3291d9f15e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Marti?= Date: Mon, 21 Oct 2024 14:06:31 +0200 Subject: [PATCH] refactor(query): removed unused boost_exact_matches (#1679) --- query/autocomplete.js | 1 - query/autocomplete_defaults.js | 1 - query/view/boost_exact_matches.js | 38 ------------------------------- 3 files changed, 40 deletions(-) delete mode 100644 query/view/boost_exact_matches.js diff --git a/query/autocomplete.js b/query/autocomplete.js index 6e980a75c..8c19661ac 100644 --- a/query/autocomplete.js +++ b/query/autocomplete.js @@ -15,7 +15,6 @@ var views = { admin_multi_match_first: require('./view/admin_multi_match_first'), admin_multi_match_last: require('./view/admin_multi_match_last'), phrase_first_tokens_only: require('./view/phrase_first_tokens_only'), - boost_exact_matches: require('./view/boost_exact_matches'), max_character_count_layer_filter: require('./view/max_character_count_layer_filter'), focus_point_filter: require('./view/focus_point_distance_filter') }; diff --git a/query/autocomplete_defaults.js b/query/autocomplete_defaults.js index bcf417986..01bcbf4bd 100644 --- a/query/autocomplete_defaults.js +++ b/query/autocomplete_defaults.js @@ -55,7 +55,6 @@ module.exports = _.merge({}, peliasQuery.defaults, { 'multi_match:type': 'cross_fields', 'multi_match:ngrams_strict:type': 'phrase', 'multi_match:first_tokens_only:type': 'phrase', - 'multi_match:boost_exact_matches:type': 'phrase', 'admin:country_a:analyzer': 'standard', 'admin:country_a:field': 'parent.country_a.ngram', diff --git a/query/view/boost_exact_matches.js b/query/view/boost_exact_matches.js deleted file mode 100644 index 39759fe77..000000000 --- a/query/view/boost_exact_matches.js +++ /dev/null @@ -1,38 +0,0 @@ -const peliasQuery = require('pelias-query'); -const searchDefaults = require('../search_defaults'); -const toMultiFields = require('./helper').toMultiFields; - -/** - This view (unfortunately) requires autocomplete to use the phrase.* index. - - ideally we wouldn't need to use this, but at time of writing we are unable - to distinguish between 'complete tokens' and 'grams' in the name.* index. - - this view was introduced in order to score exact matches higher than partial - matches, without it we find results such as "Clayton Avenue" appearing first - in the results list for the query "Clay Av". - - the view uses some of the values from the 'search_defaults.js' file to add an - additional 'SHOULD' condition which scores exact matches slighly higher - than partial matches. -**/ - -module.exports = function( vs ){ - const view_name = 'boost_exact_matches'; - - // get a copy of the *complete* tokens produced from the input:name - const tokens = vs.var('input:name:tokens_complete').get(); - - // no valid tokens to use, fail now, don't render this view. - if( !tokens || tokens.length < 1 ){ return null; } - - // set 'input' to be only the fully completed characters - vs.var(`multi_match:${view_name}:input`).set( tokens.join(' ') ); - vs.var(`multi_match:${view_name}:fields`).set(toMultiFields(searchDefaults['phrase:field'], vs.var('lang').get())); - - vs.var(`multi_match:${view_name}:analyzer`).set(searchDefaults['phrase:analyzer']); - vs.var(`multi_match:${view_name}:boost`).set(vs.var('phrase:boost').get()); - vs.var(`multi_match:${view_name}:slop`).set(vs.var('phrase:slop').get()); - - return peliasQuery.view.leaf.match_phrase(view_name)( vs ); -};