Skip to content

Highlighting does not work when all fields are type keyword #21636

@nostrebor

Description

@nostrebor

Elasticsearch version: 5.0

Plugins installed: N/A

JVM version: 1.8u112

OS version: Windows Server 2012

Description of the problem including expected versus actual behavior: Highlighting dynamic fields which are stored as keyword is not working as expected. When searching over _all I would expect highlighting to occur on all fields of the result when using require_field_match: false. Example query can be found here:

http://pastebin.com/sAGczFhU

My use case is that nearly every search is done for an exact value or over _all. I could get extreme performance gains by shifting dynamically created fields to Keyword, and then if full-text search is needed, defining them explicitly in the mapping. However, search highlighting is still an important part of our workflow.

Do I have a misunderstanding of how highlighting works? My interpretation is that

  1. We search over _all
  2. Hits are selected for highlighting as a postprocessing step
  3. Each field is matched against the original search query if require_field_match: false is set to true and the highlighting_query option is unused.

Steps to reproduce:

  1. Create a new index with a mapping that sets dynamic fields to type Keyword
  2. Add three new documents with "message": "Kostya Test"
  3. Run the previous query (fixing the date range)

Expected: There should be highlighted search text extracted from the _source fields that are loaded at highlight-time
Actual: No text is highlighted

The same can be repeated where the search is an exact match for the field, and no highlighting is done then either.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions