-
Notifications
You must be signed in to change notification settings - Fork 25k
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
Emulate "fields" option on older versions #75745
Conversation
fd0c79e
to
417a657
Compare
We introduced the new "fields" option in search with version 7.10. With this change we are trying to do a best-effort attempt at emulating this new behaviour in mixed cluster or CCS scenarios where search requests using the "fields" option also target older nodes or clusters. In that case, currently we don't return anything in the "fields" section of the response. This change tried to emulate the fields behaviour by modifying the request to include the respective "_source" fields and then parsing them back into the "fields" section on return. This will not be fully equivalent to the post-7.10 "fields" functionality but at least try to include whatever we find in "_source" in earlier versions. Currently Draft only, needs more testing in CCS scenarios but I'm opening this here already to get some test coverage on the modifications so far.
9cf4afb
to
813d011
Compare
cc8fb8c
to
83fdb97
Compare
aa42c03
to
a05f7b6
Compare
Pinging @elastic/es-search (Team:Search) |
I think this is ready for a first general view. Known caveats: currently for mixed clusters only the default |
f6d331f
to
8859c21
Compare
server/src/main/java/org/elasticsearch/action/search/TransportSearchAction.java
Outdated
Show resolved
Hide resolved
One general open question here is if we should put this bwc emulation behaviour behind a flag. I, for example, would prefer something like an "enable_fields_emulation" option on the "fields" parameter itself that's off by default and would only exist on 7.x branches going forwards (we don't need this emulation behaviour on 8+). That way clients interested in this best-effort emulation would need to consciously opt in to it with all the known limitations (only fetching from source, no formatting, no dfs-query-then-fetch). |
I added another commit that adds an "enable_fields_emulation" request parameter that switches the bwc behaviour off by default but can be enabled explicitely. We can always revert that change if we decide we don't want to do that. |
098cce1
to
7f48b54
Compare
@jimczi thanks for the first round of reviews, I pushed some small changes and left questions regarding you other comments. |
Just to double check, when "_source" is disabled in a remote target index mapping, we will get an exception. This is the same as for non-CCS searches with source filtering or if the "fields" option is used on indices with disabled source, so I think we don't need any extra treatment here. |
@jimczi while adressing your review comments I found several ways to imporve and simplify the adapter class. In previous revisions the adapter and the internal field fetcher were created too often. Now the adapter only holds the basic information from the original request (like the fact that we need fields emulation at all and references that are needed to create the field fetcher later), and only creates more expensive resources like the field fetcher only once and when needed. |
I pushed a commit now that disables "minimize_roundtrip" for all requests that have the "fields emulation" enablement flag set and a non-empty fetch-fields parameter. This means that a potential "minimize_roundtrip=true" setting will be disregarded in that case. I don't know if that is a restriction we can live with and if that was the intention of the previous comment here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change looks good to me. Thanks @cbuescher !
server/src/main/java/org/elasticsearch/action/search/FieldsOptionSourceAdapter.java
Outdated
Show resolved
Hide resolved
The intent is to use this option in |
To summarize the usage of the emulation layer:
|
This reverts commit 5a83dcd.
Reverted since the serialization logic needs adapting, otherwise we break bwc for tranport on master |
We introduced the new "fields" option in search with version 7.10. With this
change we are trying to do a best-effort attempt at emulating this new behaviour
in mixed cluster or CCS scenarios where search requests using the "fields"
option also target older nodes or clusters. In that case, currently we don't
return anything in the "fields" section of the response.
This change tries to emulate the fields behaviour by modifying the request to
include the respective "_source" fields and then parsing them back into the
"fields" section on return. This will not be fully equivalent to the post-7.10 "fields"
functionality but at least try to include whatever we find in "_source" in earlier
versions.