-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
Allow index filtering in field capabilities API #57276
Conversation
This change allows to use an `index_filter` in the field capabilities API. Indices are filtered from the response if the provided query rewrites to `match_none` on every shard: ```` GET metrics-* { "index_filter": { "bool": { "must": [ "range": { "@timestamp": { "gt": "2019" } } } } } ```` The filtering is done on a best-effort basis, it uses the can match phase to rewrite queries to `match_none` instead of fully executing the request. The first shard that can match the filter is used to create the field capabilities response for the entire index. Closes elastic#56195
Pinging @elastic/es-search (:Search/Search) |
static Request fieldCaps(FieldCapabilitiesRequest fieldCapabilitiesRequest) { | ||
Request request = new Request(HttpGet.METHOD_NAME, endpoint(fieldCapabilitiesRequest.indices(), "_field_caps")); | ||
static Request fieldCaps(FieldCapabilitiesRequest fieldCapabilitiesRequest) throws IOException { | ||
String methodName = fieldCapabilitiesRequest.indexFilter() != null ? HttpPut.METHOD_NAME : HttpGet.METHOD_NAME; |
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.
PUT? shouldn't it be a POST?
server/src/main/java/org/elasticsearch/action/fieldcaps/FieldCapabilitiesIndexRequest.java
Outdated
Show resolved
Hide resolved
@@ -67,6 +67,7 @@ public TransportFieldCapabilitiesAction(TransportService transportService, Clust | |||
|
|||
@Override | |||
protected void doExecute(Task task, FieldCapabilitiesRequest request, final ActionListener<FieldCapabilitiesResponse> listener) { | |||
long nowInMillis = request.nowInMillis() == null ? System.currentTimeMillis() : request.nowInMillis(); |
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.
question: in what cases would the current timestamp already be set?
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.
If the action is executed by a cross cluster search. See https://github.com/elastic/elasticsearch/pull/57276/files?file-filters%5B%5D=.java#diff-7bbfa44263f4c8fc5d8620e78cfe088bR130.
I added a comment in fb3007c
.../src/main/java/org/elasticsearch/action/fieldcaps/TransportFieldCapabilitiesIndexAction.java
Outdated
Show resolved
Hide resolved
qa/multi-cluster-search/src/test/resources/rest-api-spec/test/remote_cluster/10_basic.yml
Show resolved
Hide resolved
query rewrites to `match_none` on every shard. | ||
+ | ||
-- | ||
[IMPORTANT] |
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.
Looks like we've duplicated this whole note, maybe we could just keep the one below?
This change allows to use an `index_filter` in the field capabilities API. Indices are filtered from the response if the provided query rewrites to `match_none` on every shard: ```` GET metrics-* { "index_filter": { "bool": { "must": [ "range": { "@timestamp": { "gt": "2019" } } } } } ```` The filtering is done on a best-effort basis, it uses the can match phase to rewrite queries to `match_none` instead of fully executing the request. The first shard that can match the filter is used to create the field capabilities response for the entire index. Closes #56195
This commit fixes the multi cluster yaml tests by restoring the number of shards to 1 for the single_doc_index (removed in elastic#57276). Closes elastic#58345
This commit introduces overloads of field_caps API that do not take a body, as a BWC change for body introduced in elastic/elasticsearch#57276
This commit introduces overloads of field_caps API that do not take a body, as a BWC change for body introduced in elastic/elasticsearch#57276 (cherry picked from commit 1f02223)
Relates: elastic/elasticsearch#57276 Co-authored-by: Russ Cam <russ.cam@elastic.co>
Relates: elastic/elasticsearch#57276 Co-authored-by: Russ Cam <russ.cam@elastic.co>
This change allows to use an
index_filter
in the field capabilities API. Indices are filtered fromthe response if the provided query rewrites to
match_none
on every shard:The filtering is done on a best-effort basis, it uses the can match phase to rewrite queries to
match_none
instead of fully executing the request. The first shard that can match the filter is used to create the field capabilities response for the entire index.Closes #56195