弹性反向查询

Elastic opposite query

我正在对像 "search all documents with G4 in name and LG in manfucaturer" 这样的经典查询使用弹性搜索。还行吧。但是,如果我有大量文档和数据库以及大量搜索词,并且我需要知道哪些文档与某些特定的多列词相匹配,该怎么办。例如:

文件:

[
    {
     "id": 5787,
     "name": "Smartphone G4",
     "manufacturer": "LG",
     "description": "The revolutionary LG G4 design can only be described as forward thinking—with a classic touch."
    },
    {
     "id": 68779,
     "name": "Smartphone S6",
     "manufacturer": "Samsung",
     "description": "The Samsung Galaxy S6 is powerful to use and beautiful to behold."
    }
]

...

条款:

[
   {
     "id": "587",
     "name": "G4",
     "manufacturer": "LG",
     "description": "classic touch"
    },
    {
     "id": "364",
     "manufacturer": "Samsung",
     "description": "galaxy s6"
    }
]

...

结果:

{
  "587": [5787],
  "364": [68779]
}

或:

{
  "5787": [587],
  "68779": [364]
}

我需要文档列表和与之对应(或相反)的术语列表。在少量条件下,应该可以将所有规则一一应用并保存匹配文档。但我有数以百万计的文件和数千个条款。因此,不可能一一应用它们。有没有别的办法?

https://www.elastic.co/guide/en/elasticsearch/reference/current/search-percolate.html正是我想要的。它可以存储您的查询并针对文档执行它们。