How can I generate a query like this?
select * from topic where field1 = "abc" and field2 = "xyz"
I've tried the following but I can't get the correct syntax:
curl -X POST "localhost:9200/topic/_search" -H 'Content-Type: application/json' -d'
{
"query": {
"terms" : {
"field1": "abc",
"field2": "xyz"
}
}
}
'
How about...
{
"query": {
"bool": {
"must": [
{
"term": {
"field1": "abc"
}
},
{
"term": {
"field2": "xyz"
}
}
]
}
}
}
The Terms Query doesn't do what you want. Instead it searches for different values within the same key.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With