vmeln
vmeln

Reputation: 1309

AND between tokens in elasticsearch

When I'm trying to search for a documents with such query (field indexed with Standard analyzer):

 "query": {
        "match": {
           "Book": "OG/44"
        }
    }

I've got terms 'OG' and '44' and the result set will contain results where could be either of these terms. What analyzer/tokenizer I should use to get results when only both of terms are present?

Upvotes: 1

Views: 130

Answers (1)

aeryaguzov
aeryaguzov

Reputation: 1163

You can set operator in match query (by default it is or)

"query": {
    "match": {
       "Book": {
           "query": "OG/44",
           "operator" : "and"
       }
    }
}

You have two tokens because standard analyzer tokenized them by slash, so if you need not this behaviour you can escape it

Upvotes: 2

Related Questions