Reputation: 1725
I basically want to do a search which is:
select all from index_name where tag = 'big data' and city = 'tokyo'
The code is:
require "elasticsearch"
client = Elasticsearch::Client.new log: true
client.search index: 'candidates', body:
{
query: {
match: {
tags: search_term
}
}
}
which works fine. When, however, I change to something like:
match: {
tags: search_term, city: 'Tokyo'
}
that is to say just adding another parameter I get an error.
I have tried adding
filter: {
city: 'Tokyo'
}
also with no success.
Thanks guys, what's the best way forward here?
Upvotes: 2
Views: 1053
Reputation: 217274
You need to check the Elasticsearch query DSL. For a simple "A and B" query you need to simply use a bool / must
query. Replace your body with this:
client.search index: 'candidates', body:
{
query: {
bool: {
must: [
{
match: {
tags: 'big data'
}
},
{
match: {
city: 'tokyo'
}
}
]
}
}
}
Upvotes: 3