-
Notifications
You must be signed in to change notification settings - Fork 24.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for aliases in queries on _index. (#46640)
Previously, queries on the _index field were not able to specify index aliases. This was a regression in functionality compared to the 'indices' query that was deprecated and removed in 6.0. Now queries on _index can specify an alias, which is resolved to the concrete index names when we check whether an index matches. To match a remote shard target, the pattern needs to be of the form 'cluster:index' to match the fully-qualified index name. Index aliases can be specified in the following query types: term, terms, prefix, and wildcard.
- Loading branch information
1 parent
ba9940b
commit 127b8d0
Showing
32 changed files
with
362 additions
and
139 deletions.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
...luster-search/src/test/resources/rest-api-spec/test/multi_cluster/90_index_name_query.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
--- | ||
setup: | ||
- do: | ||
indices.create: | ||
index: single_doc_index | ||
body: | ||
settings: | ||
index: | ||
number_of_shards: 1 | ||
number_of_replicas: 0 | ||
--- | ||
teardown: | ||
- do: | ||
indices.delete: | ||
index: single_doc_index | ||
ignore_unavailable: true | ||
|
||
--- | ||
"Test that queries on _index match against the correct indices.": | ||
|
||
- do: | ||
bulk: | ||
refresh: true | ||
body: | ||
- '{"index": {"_index": "single_doc_index"}}' | ||
- '{"f1": "local_cluster", "sort_field": 0}' | ||
|
||
- do: | ||
search: | ||
rest_total_hits_as_int: true | ||
index: "single_doc_index,my_remote_cluster:single_doc_index" | ||
body: | ||
query: | ||
term: | ||
"_index": "single_doc_index" | ||
|
||
- match: { hits.total: 1 } | ||
- match: { hits.hits.0._index: "single_doc_index"} | ||
- match: { _shards.total: 2 } | ||
- match: { _shards.successful: 2 } | ||
- match: { _shards.skipped : 0} | ||
- match: { _shards.failed: 0 } | ||
|
||
- do: | ||
search: | ||
rest_total_hits_as_int: true | ||
index: "single_doc_index,my_remote_cluster:single_doc_index" | ||
body: | ||
query: | ||
term: | ||
"_index": "my_remote_cluster:single_doc_index" | ||
|
||
- match: { hits.total: 1 } | ||
- match: { hits.hits.0._index: "my_remote_cluster:single_doc_index"} | ||
- match: { _shards.total: 2 } | ||
- match: { _shards.successful: 2 } | ||
- match: { _shards.skipped : 0} | ||
- match: { _shards.failed: 0 } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.