I want to search with two fields in ElasticSearch, fields are:
1) SearchTerm (Textfield)
2) City (Textfield)
If I use mysql Query would be:
if both has value
select * from table where term = 'abc' AND city = 'mexico'
if only term has value
select * from table where term = 'abc'
if only city has value
select * from table where city = 'mexico'
How can I use this in ElasticSearch I'm trying with the following:
"bool" : {
"should": [
{
"multi_match": {
"query": '"'+term.toLowerCase()+'"',
"fields":
[
"title", "desc"
],
"operator" : "and"
}
},
{
"wildcard": {
"city": {
value: city.toLowerCase()
}
}
}
],
}
Please help
Thanks
Randheer