How to exactly match multi value fields?


(Xudong You) #1

I have docs something like this:

{
"tags", ["tag11", "tag12", "tag13"]
}

{
"tags", ["tag21", "tag22"]
}

I want to search for documents with exactly matched tags

e.g., if I search ["tag11", "tag12", "tag13"] it will return doc 1, but if I search ["tag11","tag12"], then Nothing return.

What is the best way ?


(Ivan Brusic) #2

You cannot, at least not easily. There is no simple way to match all the
tokens in the document/field with the ones in the query (the inverse is
easy with minimum_match). There are a few hacks. You can index the size of
the array and match it with the same of the query term. You could also use
a function score script, but there is a performance penalty of course.


(system) #3