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

.sourceExclude and .sourceInclude are mutually exclusive #3017

Closed
tastyminerals opened this issue Feb 28, 2024 · 1 comment · Fixed by #3059
Closed

.sourceExclude and .sourceInclude are mutually exclusive #3017

tastyminerals opened this issue Feb 28, 2024 · 1 comment · Fixed by #3059

Comments

@tastyminerals
Copy link

tastyminerals commented Feb 28, 2024

Currently you can't use sourceExclude and sourceInclude together when constructing a SearchRequest. The latter will overwrite the former.

val request = search("test_index")
  .query(matchAllQuery)
  .sourceExclude(Seq("doc_id"))
  .sourceInclude(Seq("user_id"))

request.show

produces

POST /upload_read/_search
{"query":{"match_all":{}},"_source":{"includes":["user_id"]}}

In case the sourceInclude(Seq.empty), the request excludes will be similarly removed completely, producing "_source":true.

This could be the intended behavior, I am not sure because there is no documentation and no tests for using both of these functions. However, the classic elasticsearch library allows it and anyone who attempts a migration will end up having nasty silent bugs.

new SearchSourceBuilder().query(query).fetchSource(Array("doc_id"), Array("user_id"))
@Philippus
Copy link
Owner

Philippus commented May 6, 2024

I've created a fix for this in #3059.

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

Successfully merging a pull request may close this issue.

2 participants