Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use cross_fields type for multi_match #116

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions test/view/admin_multi_match.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' }
}
};

Expand All @@ -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' }
}
};

Expand Down
9 changes: 9 additions & 0 deletions view/admin_multi_match.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down