Reputation: 129
I'm new to ES and want to setup a query to search on multiple terms.
My SQL looks like:
"SELECT field4 FROM tablename WHERE (field1 = 'A' OR field1 = 'AA') AND (field2 = 'B' OR fields2 = 'BB') AND (field3 = 'C' OR field3 = 'CC')"
In ES I'm trying
{
"query": {
"bool": {
"must": [
{
"term": {
"field1": {"A","AA"}
}
},
{
"term": {
"field2": {"B","BB"}
}
},
{
"term": {
"field3": {"C","CC"}
}
}
}
}
}
Upvotes: 0
Views: 205
Reputation: 1256
What you most likely want is a terms
query. You can see the documentation for it here: https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-terms-query.html
An example from that site is:
{
"terms" : { "user" : ["kimchy", "elasticsearch"]}
}
Also, your query right now isn't valid json, you'll need to correct it.
Upvotes: 2