Reputation: 45
I need to query 3000 data from ElasticSearch, and currently I am using multi_match for querying. Is there a way to match using an array of strings? Term is not usable as it only queries the exact value of the string.
Below is an example of an ideal request:
{
"size": 1,
"_source": ["_id"],
"query": {
"multi_match": {
"query": ["val1", "val2"],
"fields": [
"name",
"url"
]
}
}
}
EDIT:
Another use case would be like searching schools:
{
"size": 1,
"_source": ["_id"],
"query": {
"multi_match": {
"query": ["school name 1", "school name 2"],
"fields": [
"name"
]
}
}
}
Consider the spaces of each values to be the whole school name.
Upvotes: 0
Views: 2171
Reputation: 217544
multi_match
doesn't accept and array of values but nothing prevents you from sending a string containing the values. The query string will be analyzed into two tokens val1
and val2
and each will be matched separately on each field.
{
"size": 1,
"_source": ["_id"],
"query": {
"multi_match": {
"query": "val1 val2",
"fields": [
"name",
"url"
]
}
}
}
Upvotes: 1