From f6593c9d88d6c32b7e2cebfc97658632062e33db Mon Sep 17 00:00:00 2001 From: missinglink Date: Thu, 14 Nov 2019 11:54:08 +0100 Subject: [PATCH 1/2] fix(admin_multi_match): use cross_fields type for multi_match --- test/view/admin_multi_match.js | 6 ++++-- view/admin_multi_match.js | 5 +++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/test/view/admin_multi_match.js b/test/view/admin_multi_match.js index 6577b9a..b6a385b 100644 --- a/test/view/admin_multi_match.js +++ b/test/view/admin_multi_match.js @@ -92,7 +92,8 @@ module.exports.tests.no_exceptions_conditions = function(test, common) { 'property2_field value^property2_boost value' ], 'query': { $: 'property1 value' }, - 'analyzer': 'analyzer value' + 'analyzer': 'analyzer value', + 'type': { $: 'cross_fields' } } }; @@ -117,7 +118,8 @@ module.exports.tests.no_exceptions_conditions = function(test, common) { 'property1_field value^1' ], 'query': { $: 'property1 value' }, - 'analyzer': 'analyzer value' + 'analyzer': 'analyzer value', + 'type': { $: 'cross_fields' } } }; diff --git a/view/admin_multi_match.js b/view/admin_multi_match.js index ff91529..0b0f57b 100644 --- a/view/admin_multi_match.js +++ b/view/admin_multi_match.js @@ -41,6 +41,11 @@ module.exports = function( admin_properties, analyzer ){ // TODO: handle the case where not all admin area input values are the same var queryVar = 'input:' + valid_admin_properties[0]; + // admin multi-matching should always use the 'cross_fields' matching type + // this is to ensure that scoring is not only based on the best matching field. + // see: https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html#multi-match-types + vs.var('multi_match:type', 'cross_fields'); + // send the parameters to the standard multi_match view var view = multi_match(vs, fields_with_boosts, analyzer, queryVar); From 7789fa1cdee0f28c17c8b8a39f150b4b1beb1a87 Mon Sep 17 00:00:00 2001 From: missinglink Date: Thu, 14 Nov 2019 12:47:21 +0100 Subject: [PATCH 2/2] fix(admin_multi_match): dissalow cutoff_frequency for admin_multi_match --- view/admin_multi_match.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/view/admin_multi_match.js b/view/admin_multi_match.js index 0b0f57b..78163ec 100644 --- a/view/admin_multi_match.js +++ b/view/admin_multi_match.js @@ -46,6 +46,10 @@ module.exports = function( admin_properties, analyzer ){ // see: https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html#multi-match-types vs.var('multi_match:type', 'cross_fields'); + // disable cutoff_frequency as most of these admin terms are very common + // and we would still like them to match and score appropriately. + vs.unset('multi_match:cutoff_frequency'); + // send the parameters to the standard multi_match view var view = multi_match(vs, fields_with_boosts, analyzer, queryVar);