Elasticsearch “Join” tables

◇◆丶佛笑我妖孽 提交于 2019-12-11 06:07:43

问题


I need to do "Join" between 2 indexes (tables) and preform a check on specific field on documents that exists in both indexes.

I want to add condition like "dateExpiry" below, but I get an error. Is it possible to join 2 or more indexes?

GET cache-*/_search
{
  "query": {
    "bool": {
      "must_not": [
        {
          "query": {
            "terms": {
              "TagId": {
                "index": "domain_block-2016.06",
                "type": "cBlock",
                "id": "57692ef6ae8c50f67e8b45",
                "path": "TagId",
               "range" : {
               "dateExpiry" : {
                   "gte" :  "20160705T12:00:00"
               }
              }
            }
          }
        }
      ]
    }
  } 
}

回答1:


Filters within a Terms Query Lookup are currently not supported. However, Elasticsearch has some great documentation on joins / relationships here.

Your best bet may be to run two queries against Elasticsearch - one to fetch the list of TagIds, then another that includes the list as an exclusion clause.



来源:https://stackoverflow.com/questions/38255852/elasticsearch-join-tables

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!