Multi-Index Search with Filters
You can combine multi-index search with filters to further refine your search results.
Example: Multi-Index Search with Filters
Let’s search for products and users where the price is less than 100.
GET /products,users/_search
{
"query": {
"bool": {
"must": {
"multi_match": {
"query": "Elasticsearch",
"fields": ["name", "description"]
}
},
"filter": {
"range": {
"price": {
"lt": 100
}
}
}
}
}
}
In this example:
- We use a bool query to combine a multi_match query (search for “Elasticsearch“) with a range filter (filter where price is less than 100).
- The filter applies to both the products and users indices.
Elasticsearch Multi Index Search
In Elasticsearch, multi-index search refers to the capability of querying across multiple indices simultaneously. This feature is particularly useful when you have different types of data stored in separate indices and need to search across them in a single query. In this article, we’ll explore what multi-index search is, why it’s important, and how to use it effectively with practical examples.
Contact Us