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..78163ec 100644 --- a/view/admin_multi_match.js +++ b/view/admin_multi_match.js @@ -41,6 +41,15 @@ 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'); + + // 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);