简体   繁体   中英

Elasticsearch - match by all terms but full field must be matched

I'm trying to improve search on my service but get stuck on complex queries. I need to match some documents by terms but return only documents that contains all of provided terms in any order and contains only this terms. So for example, lets take movie titles: "Jurassic Park" "Lost World: Jurassic Park" "Jurassic Park III"

When I type "Park Jurassic" I want only first document to be returned because it contains both words and nothing more.

This is silly example of complex problem but I've simplified it.

I tried with terms queries, match etc but I don't know how to check if entire field was matched.

So in short it must match all tokens in any order. Field is mapped as text and also as keyword.

You tested the terms set query ?

Returns documents that contain a minimum number of exact terms in a provided field.

The terms_set query is the same as the terms query, except you can define the number of matching terms required to return a document.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM