Skip to content

Commit 30b6634

Browse files
committed
[DOCS] Search multiple indices added info
1 parent 393ea61 commit 30b6634

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

docs/reference/search/search-your-data/search-multiple-indices.asciidoc

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
[[search-multiple-indices]]
2-
=== Search multiple data streams and indices
2+
=== Search multiple data streams and indices using a query
3+
4+
There are two primary ways to search across multiple data streams and indices:
5+
6+
* At the query level: Specify the indices directly in the search request path or use index patterns to target a group of indices.
7+
8+
* At the index level: Use <<aliases, index aliases>>, which act as pointers to one or more backing indices, allowing you to group and manage indices logically.
39

410
To search multiple data streams and indices, add them as comma-separated values
511
in the <<search-search,search API>>'s request path.
@@ -39,6 +45,33 @@ GET /my-index-*/_search
3945
----
4046
// TEST[setup:my_index]
4147

48+
You can also remove a subset of indices from being searched. The request will retun data from all indices that start with `my-index-` while excluding results from `my-index-01`.
49+
50+
[source,console]
51+
----
52+
GET /my-index-*/_search
53+
{
54+
"query": {
55+
"bool": {
56+
"must": [
57+
{
58+
"match": {
59+
"user.id": "kimchy"
60+
}
61+
}
62+
],
63+
"must_not": [
64+
{
65+
"terms": {
66+
"_index": ["my-index-01"]
67+
}
68+
}
69+
]
70+
}
71+
}
72+
}
73+
----
74+
4275
To search all data streams and indices in a cluster, omit the target from the
4376
request path. Alternatively, you can use `_all` or `*`.
4477

0 commit comments

Comments
 (0)