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

Can't retrieve stored fields as part of inner hits #9766

Closed
tstibbs opened this issue Feb 19, 2015 · 5 comments · Fixed by #10235
Closed

Can't retrieve stored fields as part of inner hits #9766

tstibbs opened this issue Feb 19, 2015 · 5 comments · Fixed by #10235
Assignees
Labels
>bug :Search/Search Search-related issues that do not fall into other categories

Comments

@tstibbs
Copy link
Contributor

tstibbs commented Feb 19, 2015

I've been trying out the new 'inner_hits' stuff (see #8153, I built a 1.5 snapshot from commit 23ef4e8 on the 1.x branch).

However, I don't seem to be able to request stored fields from my nested documents. It would be great to be able to specify a 'fields' element as part of the nested hit.

Note that Martijn's comment in #8153 (comment) suggested it is possible, but I couldn't work out how...

As a side note, that comment was suggested in relation to disabling the source. In my case I was trying to disable the source for just the nested children, by adding the following to my mapping:

"_source" : {
    "excludes" : ["nested_field", "nested_field.*"]
}

which resulted in a null pointer exception...

java.lang.NullPointerException
    at org.elasticsearch.search.fetch.FetchPhase.createNestedSearchHit(FetchPhase.java:295)
    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)
    at org.elasticsearch.search.action.SearchServiceTransportAction$17.call(SearchServiceTransportAction.java:452)
    at org.elasticsearch.search.action.SearchServiceTransportAction$17.call(SearchServiceTransportAction.java:449)
    at org.elasticsearch.search.action.SearchServiceTransportAction$23.run(SearchServiceTransportAction.java:559)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:744)
@clintongormley
Copy link

The NPE sounds like a bug, because inner hits is expecting the source to be there. You should be able to use the fields parameter to retrieve stored fields though (at least according to the docs: http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/search-request-inner-hits.html#nested-inner-hits )

@tstibbs
Copy link
Contributor Author

tstibbs commented Mar 5, 2015

@clintongormley yeah, I noticed the docs say you can use fields, but it doesn't tell you where to put the fields element within the inner_hits element - I've tried a whole bunch of different places but can't make any of them do anything other than give me a parse error. Looking at InnerHitsParseElement and InnerHitsQueryParserHelper etc I can't see it looking for fields so I think probably the docs are wrong in this case.

@martijnvg
Copy link
Member

@tstibbs I referred to disabling the entire source and I think in your case you only leave out the nested part of your source. I see how this can result into the NPE you're describing.

@tstibbs
Copy link
Contributor Author

tstibbs commented Mar 24, 2015

@martijnvg yep, I noticed that, just thought I'd report the NPE as it's presumably a bug (though a pretty minor one).

My original point about not being able to retrieve stored fields (e.g. if you disable the entire source) is still valid though I think.

@martijnvg
Copy link
Member

@tstibbs I opened #10235 in order to fix the stored field support in inner hits (it was supported, but forgot to add the parsing support for stored fields) and address the NPE you have found.

martijnvg added a commit to martijnvg/elasticsearch that referenced this issue Mar 28, 2015
This also fixes a NPE when the nested part has been filtered out of the _source, because of _source filtering.

Closes elastic#9766
martijnvg added a commit to martijnvg/elasticsearch that referenced this issue Mar 28, 2015
This also fixes a NPE when the nested part has been filtered out of the _source, because of _source filtering.

Closes elastic#9766
martijnvg added a commit that referenced this issue Mar 28, 2015
This also fixes a NPE when the nested part has been filtered out of the _source, because of _source filtering.

Closes #9766
mute pushed a commit to mute/elasticsearch that referenced this issue Jul 29, 2015
This also fixes a NPE when the nested part has been filtered out of the _source, because of _source filtering.

Closes elastic#9766
@clintongormley clintongormley added :Search/Search Search-related issues that do not fall into other categories and removed :Inner Hits labels Feb 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Search/Search Search-related issues that do not fall into other categories
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants