- Learning Elastic Stack 7.0(Second Edition)
- Pranav Shukla Sharath Kumar M N
- 103字
- 2025-04-04 14:18:54
Querying multiple fields with defaults
We want to provide a product search functionality in our web application. When the end user searches for some terms, we want to query both the title and description fields. This can be done using the multi_match query.
The following query will find all of the documents that have the terms monitor or aquarium in the title or the description fields:
GET /amazon_products/_search
{
"query": {
"multi_match": {
"query": "monitor aquarium",
"fields": ["title", "description"]
}
}
}
This query gives equal importance to both fields. Let's look at how to boost one or more fields.