diff --git a/src/core/highlight.js b/src/core/highlight.js index 4b4d596..d38f3e6 100644 --- a/src/core/highlight.js +++ b/src/core/highlight.js @@ -19,7 +19,7 @@ const invalidEncoderParam = invalidParam( const invalidTypeParam = invalidParam( ES_REF_URL, 'type', - "'plain', 'postings' or 'fvh'" + "'plain', 'postings', 'unified' or 'fvh'" ); const invalidFragmenterParam = invalidParam( ES_REF_URL, @@ -452,10 +452,10 @@ class Highlight { * @example * const highlight = esb.highlight('content').type('plain', 'content'); * - * @param {string} type The allowed values are: `plain`, `postings` and `fvh`. + * @param {string} type The allowed values are: `plain`, `postings`, `unified` and `fvh`. * @param {string=} field An optional field name * @returns {Highlight} returns `this` so that calls can be chained - * @throws {Error} Type can be one of `plain`, `postings` or `fvh`. + * @throws {Error} Type can be one of `plain`, `postings`, `unified` or `fvh`. */ type(type, field) { if (isNil(type)) invalidTypeParam(type); @@ -464,6 +464,7 @@ class Highlight { if ( typeLower !== 'plain' && typeLower !== 'postings' && + typeLower !== 'unified' && typeLower !== 'fvh' ) { invalidTypeParam(type); diff --git a/src/index.d.ts b/src/index.d.ts index 45c46a9..5c5f129 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -8932,11 +8932,11 @@ declare namespace esb { * Note: The `postings` highlighter has been removed in elasticsearch 6.0. The `unified` * highlighter outputs the same highlighting when `index_options` is set to `offsets`. * - * @param {string} type The allowed values are: `plain`, `postings` and `fvh`. + * @param {string} type The allowed values are: `plain`, `postings`, `unified` and `fvh`. * @param {string=} field An optional field name - * @throws {Error} Type can be one of `plain`, `postings` or `fvh`. + * @throws {Error} Type can be one of `plain`, `postings`, `unified` or `fvh`. */ - type(type: 'plain' | 'postings' | 'fvh', field?: string): this; + type(type: 'plain' | 'postings' | 'unified' | 'fvh', field?: string): this; /** * Forces the highlighting to highlight fields based on the source diff --git a/test/core-test/highlight.test.js b/test/core-test/highlight.test.js index 77c1409..831ecd4 100644 --- a/test/core-test/highlight.test.js +++ b/test/core-test/highlight.test.js @@ -106,7 +106,12 @@ test(illegalParamType, new Highlight(), 'fields', 'Array'); test(illegalParamType, new Highlight(), 'highlightQuery', 'Query'); test(illegalParamType, new Highlight(), 'matchedFields', 'Array'); test(validatedCorrectly, highlight, 'encoder', ['default', 'html']); -test(validatedCorrectly, highlight, 'type', ['plain', 'postings', 'fvh']); +test(validatedCorrectly, highlight, 'type', [ + 'plain', + 'postings', + 'unified', + 'fvh' +]); test(validatedCorrectly, highlight, 'fragmenter', ['simple', 'span']); test(setHighlightOption, 'preTags', ['', '']); test('sets pre_tags(str) option', setHighlightOption, 'preTags', '', [