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

NullPointerException when applying a sort and using ignoreMapped(true) and the field does not exist (0.20.5) #2711

Closed
GrantGochnauer opened this issue Feb 28, 2013 · 3 comments

Comments

@GrantGochnauer
Copy link

code:
SortBuilder sortBuilder = SortBuilders.fieldSort(query.getSortField()).ignoreUnmapped(true);
sortBuilder.order(query.getSortOrder());

Result:
org.elasticsearch.search.builder.SearchSourceBuilderException: Failed to build search source
at org.elasticsearch.search.builder.SearchSourceBuilder.buildAsBytes(SearchSourceBuilder.java:559)
at org.elasticsearch.action.search.SearchRequest.source(SearchRequest.java:251)
at org.elasticsearch.action.search.SearchRequestBuilder.doExecute(SearchRequestBuilder.java:814)
at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:62)
at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:57)
at
...........
Caused by: java.lang.NullPointerException
at org.elasticsearch.common.jackson.dataformat.smile.SmileGenerator._writeFieldName(SmileGenerator.java:580)
at org.elasticsearch.common.jackson.dataformat.smile.SmileGenerator.writeFieldName(SmileGenerator.java:453)
at org.elasticsearch.common.xcontent.json.JsonXContentGenerator.writeFieldName(JsonXContentGenerator.java:74)
at org.elasticsearch.common.xcontent.XContentBuilder.field(XContentBuilder.java:267)
at org.elasticsearch.common.xcontent.XContentBuilder.startObject(XContentBuilder.java:136)
at org.elasticsearch.search.sort.FieldSortBuilder.toXContent(FieldSortBuilder.java:78)
at org.elasticsearch.search.builder.SearchSourceBuilder.toXContent(SearchSourceBuilder.java:673)
at org.elasticsearch.search.builder.SearchSourceBuilder.buildAsBytes(SearchSourceBuilder.java:556)
... 100 more

s1monw added a commit to s1monw/elasticsearch that referenced this issue Feb 28, 2013
@ghost ghost assigned s1monw Mar 1, 2013
@s1monw
Copy link
Contributor

s1monw commented Mar 1, 2013

hey, it seems you application is passing a null field in the FieldSortBuilder constructor, I agree we should throw an exception earlier and for sure no NPE but it seems like a bug in your code?

@GrantGochnauer
Copy link
Author

Hi Simon, thanks for the reply. I'll double check that no nulls are being passed in.

@s1monw
Copy link
Contributor

s1monw commented Mar 3, 2013

i pushed this to 0.20 as well

mute pushed a commit to mute/elasticsearch that referenced this issue Jul 29, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants