From dea46e2935ef3c862d33161e4e3e770c38c4050d Mon Sep 17 00:00:00 2001 From: Bruce Chu Date: Sun, 4 Jan 2015 16:36:28 -0800 Subject: [PATCH] fix for multi_match query to support type in ['best_fields', 'cross_fields', 'most_fields'] --- dist/elastic.js | 6 +++--- src/query/MultiMatchQuery.js | 2 +- tests/query_test.js | 14 +++++++++++--- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/dist/elastic.js b/dist/elastic.js index 7aca7ed..f327384 100644 --- a/dist/elastic.js +++ b/dist/elastic.js @@ -1,6 +1,6 @@ -/*! elastic.js - v1.2.0 - 2014-10-13 +/*! elastic.js - v1.2.0 - 2015-01-04 * https://github.com/fullscale/elastic.js - * Copyright (c) 2014 FullScale Labs, LLC; Licensed MIT */ + * Copyright (c) 2015 FullScale Labs, LLC; Licensed MIT */ /** @namespace @@ -12623,7 +12623,7 @@ } type = type.toLowerCase(); - if (type === 'boolean' || type === 'phrase' || type === 'phrase_prefix') { + if (type === 'best_fields' || type === 'most_fields' || type === 'cross_fields' || type === 'phrase' || type === 'phrase_prefix') { query.multi_match.type = type; } diff --git a/src/query/MultiMatchQuery.js b/src/query/MultiMatchQuery.js index 26a10e4..4bccb95 100644 --- a/src/query/MultiMatchQuery.js +++ b/src/query/MultiMatchQuery.js @@ -280,7 +280,7 @@ } type = type.toLowerCase(); - if (type === 'boolean' || type === 'phrase' || type === 'phrase_prefix') { + if (type === 'best_fields' || type === 'most_fields' || type === 'cross_fields' || type === 'phrase' || type === 'phrase_prefix') { query.multi_match.type = type; } diff --git a/tests/query_test.js b/tests/query_test.js index 02efc16..1fc2166 100644 --- a/tests/query_test.js +++ b/tests/query_test.js @@ -1985,7 +1985,7 @@ exports.queries = { test.done(); }, MultiMatchQuery: function (test) { - test.expect(45); + test.expect(47); var mmQuery = ejs.MultiMatchQuery('t', 'v1'), expected, @@ -2032,8 +2032,16 @@ exports.queries = { expected.multi_match.tie_breaker = 0.6; doTest(); - mmQuery.type('boolean'); - expected.multi_match.type = 'boolean'; + mmQuery.type('best_fields'); + expected.multi_match.type = 'best_fields'; + doTest(); + + mmQuery.type('cross_fields'); + expected.multi_match.type = 'cross_fields'; + doTest(); + + mmQuery.type('most_fields'); + expected.multi_match.type = 'most_fields'; doTest(); mmQuery.type('junk');