2021年2月5日星期五

Elasticsearch match only and exactly given tags in tags array

As an example, there are four documents

{id: 1, tags :["cat", "dog", "horse"]}  {id: 2, tags :["dog", "cat"]}  {id: 3, tags :["cat"]}  {id: 4, tags :["dog"]}  
  1. If I query tags with ["cat"] I should only get {id: 3, tags :["cat"]}

  2. If I query tags with ["dog"] I should only get {id: 4, tags :["dog"]}

How can I construct such a query?

https://stackoverflow.com/questions/66069294/elasticsearch-match-only-and-exactly-given-tags-in-tags-array February 06, 2021 at 03:15AM

没有评论:

发表评论