1
votes

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?

1
Maybe you need to escape slash in query or when indexing value? - aeryaguzov
But that would be one token isn't it? - vmeln
Yep. Do you need to have two tokens and query for them both ? - aeryaguzov
It depends, I don't know if I will get result like 'OG/44/13' with escaped query. I can't change client code radically. - vmeln

1 Answers

2
votes

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