Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Single nested child can cause ClassCastException when requesting inner_hits #9723

Closed
tstibbs opened this issue Feb 17, 2015 · 0 comments
Closed
Assignees
Labels

Comments

@tstibbs
Copy link
Contributor

tstibbs commented Feb 17, 2015

Just been trying out a 1.5 snapshot (built from commit 75b6d8e from the 1.x branch) to request inner hits.

If your mapping has a 'nested' type and you specify your child document as an object rather than an array, you get a ClassCastException. I.e. your doc looks like this:

{
  "nested_field": {
    "make": "ford"
  }
}

When searching you will get an exception like this:

java.lang.ClassCastException: java.util.LinkedHashMap cannot be cast to java.util.List
at org.elasticsearch.search.fetch.FetchPhase.createNestedSearchHit(FetchPhase.java:294)
at org.elasticsearch.search.fetch.FetchPhase.execute(FetchPhase.java:178)
at org.elasticsearch.search.fetch.innerhits.InnerHitsFetchSubPhase.hitExecute(InnerHitsFetchSubPhase.java:96)
at org.elasticsearch.search.fetch.FetchPhase.execute(FetchPhase.java:190)
at org.elasticsearch.search.SearchService.executeFetchPhase(SearchService.java:501)

Note that it works ok if you index your document like this (note the extra square brackets to indicate an array)

{
  "nested_field": [
    {
      "make": "ford"
    }
  ]
}

I think that either the nested hits stuff should support this single child using the non-array format, or elasticsearch should throw an error when you try to index a document using that syntax.

(note this issue came out of a comment on pull request #8153)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants