Reputation: 5651
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"
}
}
}
'
Upvotes: 3
Views: 4282
Reputation: 1016
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.
Upvotes: 4