Query with match by multiple fields
I'm pretty new to elastic search and would like to write a query that is concerned about two fields. I mean the content of the fields contains the specified substring. I have a document containing fields, like this:
name: n
tag: t
I tried this:
/_search -d '
{
"query": {
"match": {
"name": "n",
"tag": "t"
}
}
}
But the query results in the following error:
[match] query parsed in simplified form, with direct field name, but included more options than just the field name, possibly use its 'options' form, with 'query' element?
Is there a way to do this in elasticsearch?
You need two match
queries enclosed in a bool/must
query, like this:
{
"query": {
"bool": {
"must": [
{
"match": {
"name": "n"
}
},
{
"match": {
"tag": "t"
}
}
]
}
}
}