Advertisements
Using elasticseach, I want to search all documents with two words.
I use:
{ "query": { "match": { "text": "word1 word2" } } }
but instead of having documents with word1 and word2, i have documents with word1 or word2.
¿how can i search docs with word1 AND word2?
>Solution :
You can use operator
in the query.
The operator parameter can be set to or or and to control the boolean
clauses (defaults to or).
POST test_index/_doc
{"text":"word1"}
POST test_index/_doc
{"text":"word2"}
POST test_index/_doc
{"text":"word1 word2"}
GET test_index/_search
{
"query": {
"match": {
"text": {
"query": "word1 word2",
"operator": "and"
}
}
}
}