From 812f00891c9dbeeb9273e481ae8b4aec9f92576c Mon Sep 17 00:00:00 2001 From: Paul Myburgh Date: Sun, 9 Feb 2020 11:16:03 +0100 Subject: [PATCH 1/2] feat: add support for type `bool_prefix` on multi-match queries and updated jsdoc comments --- src/core/consts.js | 3 ++- src/index.d.ts | 5 ++++- src/queries/full-text-queries/multi-match-query.js | 6 +++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/core/consts.js b/src/core/consts.js index e282acdb..642a07f1 100644 --- a/src/core/consts.js +++ b/src/core/consts.js @@ -52,7 +52,8 @@ exports.MULTI_MATCH_TYPE = new Set([ 'most_fields', 'cross_fields', 'phrase', - 'phrase_prefix' + 'phrase_prefix', + 'bool_prefix' ]); exports.SCORE_MODE_SET = new Set([ diff --git a/src/index.d.ts b/src/index.d.ts index c5abf585..427a14e0 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -732,9 +732,11 @@ declare namespace esb { * the `_score` from each field. * - `phrase_prefix` - Runs a `match_phrase_prefix` query on each field * and combines the `_score` from each field. + * - `bool_prefix` - Creates a match_bool_prefix query on each field and + * combines the _score from each field. * * @param {string} type Can be one of `best_fields`, `most_fields`, - * `cross_fields`, `phrase`, and `phrase_prefix`. Default is `best_fields`. + * `cross_fields`, `phrase`, `phrase_prefix` and `bool_prefix`. Default is `best_fields`. */ type( type: @@ -743,6 +745,7 @@ declare namespace esb { | 'cross_fields' | 'phrase' | 'phrase_prefix' + | 'bool_prefix' ): this; /** diff --git a/src/queries/full-text-queries/multi-match-query.js b/src/queries/full-text-queries/multi-match-query.js index 2d3d09fb..bd472077 100644 --- a/src/queries/full-text-queries/multi-match-query.js +++ b/src/queries/full-text-queries/multi-match-query.js @@ -114,6 +114,9 @@ class MultiMatchQuery extends FullTextQueryBase { * - `phrase_prefix` - Runs a `match_phrase_prefix` query on each field * and combines the `_score` from each field. * + * - `bool_prefix` - Creates a match_bool_prefix query on each field and + * combines the _score from each field. + * * @example * // Find the single best matching field * const qry = esb.multiMatchQuery(['subject', 'message'], 'brown fox') @@ -141,7 +144,8 @@ class MultiMatchQuery extends FullTextQueryBase { * .operator('and'); * * @param {string} type Can be one of `best_fields`, `most_fields`, - * `cross_fields`, `phrase`, and `phrase_prefix`. Default is `best_fields`. + * `cross_fields`, `phrase`, `phrase_prefix` and `bool_prefix`. Default is + * `best_fields`. * @returns {MultiMatchQuery} returns `this` so that calls can be chained. */ type(type) { From 7ffbf91ef7cbe999bb2db35c076a54b72ad07d08 Mon Sep 17 00:00:00 2001 From: Paul Myburgh Date: Mon, 10 Feb 2020 11:31:00 +0100 Subject: [PATCH 2/2] Added in bool_prefix version --- src/index.d.ts | 2 +- src/queries/full-text-queries/multi-match-query.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.d.ts b/src/index.d.ts index 427a14e0..548e0e26 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -732,7 +732,7 @@ declare namespace esb { * the `_score` from each field. * - `phrase_prefix` - Runs a `match_phrase_prefix` query on each field * and combines the `_score` from each field. - * - `bool_prefix` - Creates a match_bool_prefix query on each field and + * - `bool_prefix` - (added in v7.2) Creates a match_bool_prefix query on each field and * combines the _score from each field. * * @param {string} type Can be one of `best_fields`, `most_fields`, diff --git a/src/queries/full-text-queries/multi-match-query.js b/src/queries/full-text-queries/multi-match-query.js index bd472077..0a47c3f7 100644 --- a/src/queries/full-text-queries/multi-match-query.js +++ b/src/queries/full-text-queries/multi-match-query.js @@ -114,7 +114,7 @@ class MultiMatchQuery extends FullTextQueryBase { * - `phrase_prefix` - Runs a `match_phrase_prefix` query on each field * and combines the `_score` from each field. * - * - `bool_prefix` - Creates a match_bool_prefix query on each field and + * - `bool_prefix` - (added in v7.2) Creates a match_bool_prefix query on each field and * combines the _score from each field. * * @example