Elasticsearch: Don't compile script fields when size is 0

Created on 5 Jul 2018  路  9Comments  路  Source: elastic/elasticsearch

Today Kibana sends the list of script fields that it may need for convenience, even if it doesn't need any hits. This may be confusing to users sometimes when this causes for instance the script compilation limit to break. While things could be improved on the Kibana side, this issue looks easy to fix in SearchService.parseSource by just ignoring script fields when size is 0.

:SearcSearch >enhancement help wanted

All 9 comments

Pinging @elastic/es-search-aggs

We discussed this in fix-it-thursday and decided this sounds like a good idea. Let's do it

@dakrone @jpountz

I would like to take this up. From what I understand, I would have to make changes in this condition and adding source.size() == 0.

Please correct me if I'm wrong.

@Parth-Vader I think it would be this line, so that script fields are not compiled or added to the search context.

Upon further thought, I also wonder whether this should be an error case? Otherwise part of the request is being silently ignored.

Failing the request is another option indeed. I guess ignoring the script has by preference since it avoids introducing a significant breaking change: to be consistent we'd have to do the same with stored fields, source filtering, highlighting or sort orders.

@rjernst @jpountz So to get started, source.scriptFields() != null && source.size() != 0 in that line? Or do we want to throw an error too?

@Parth-Vader We're still having second thoughts regarding whether we want to raise an error, let's give @rjernst a chance to comment.

While I think erroring would be better, @Parth-Vader could certainly implement the very simple optimization proposed, and deprecation/error could come later.

@rjernst @jpountz Thanks, I've made this PR #31917.

Was this page helpful?
0 / 5 - 0 ratings