Skip to content

Highlighting fails with a cryptic error when issuing a custom query #6287

@rmarone

Description

@rmarone

I'm aware parent child queries are not officially supported, but elasticsearch custom DSL queries are. Upon upgrading from 4.2.1 to 4.3.0 (and still present in 4.4.1) I found that queries that used to work no longer did so.

After quite a bit of tracking down, I found that highlighting was responsible.

Steps to reproduce

curl -XDELETE http://localhost:9200/parent_child
curl -XPUT    http://localhost:9200/parent_child -d '{
  "mappings": {
    "child_type": {
      "properties": {
        "count": {
          "type": "integer"
        }
      },
      "_parent": {
        "type": "parent_type"
      }
    },
    "parent_type": {
      "properties": {
        "name": {
          "type": "string"
        }
      }
    }
  }
}'

curl -XPOST http://localhost:9200/parent_child/_bulk -d'
{ "index": {"_id": 1, "_type": "parent_type" }}
{ "name": "foo" }
{ "index": {"_id": 2, "_parent": 1, "_type": "child_type" }}
{ "count": 2}
{ "index": {"_id": 3, "_parent": 1, "_type": "child_type" }}
{ "count": 2}
'

kibana1

kibana2

Issue the query:
{"has_parent":{"query":{"match":{"name":"foo"}},"type":"parent_type"}}

Results in:
kibana3

Elasticsearch logs showing the error(for reference)

[2016-02-19 15:53:14,966][DEBUG][action.search.type ] [Colonel] [649] Failed to execute fetch phase
RemoteTransportException[[Colonel][127.0.0.1:9300][indices:data/read/search[phase/fetch/id]]]; nested: FetchPhaseExecutionException[Fetch Failed [Failed to highlight field [_routing]]]; nested: IllegalStateException[can't load global ordinals for reader of type: class org.apache.lucene.search.highlight.WeightedSpanTermExtractor$DelegatingLeafReader must be a DirectoryReader];
Caused by: FetchPhaseExecutionException[Fetch Failed [Failed to highlight field [_routing]]]; nested: IllegalStateException[can't load global ordinals for reader of type: class org.apache.lucene.search.highlight.WeightedSpanTermExtractor$DelegatingLeafReader must be a DirectoryReader];
at org.elasticsearch.search.highlight.PlainHighlighter.highlight(PlainHighlighter.java:123)

Upon changing kibana settings to disable highlighting, this same search will return the expected results.

kibana5

In my opinion highlighting causing any search to not function is unreasonable.

Suggestions for potential solutions include:

  • Don't highlight for searches in the Elasticsearch Query DSL
  • If a query fails with an error due to highlighting, reissue the search without highlighting
  • Anything else you guys can come up with : )

Metadata

Metadata

Assignees

Labels

Feature:DiscoverDiscover ApplicationFeature:HighlightHighlighting of content via queryTeam:VisualizationsTeam label for Lens, elastic-charts, Graph, legacy editors (TSVB, Visualize, Timelion) t//bugFixes for quality problems that affect the customer experiencefeedback_neededstill valid?

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions