使用more_like_this查询进行搜索时是否可以同时查询多个elasticsearch索引?

我正在用python构建查询,但我认为这并不重要。这是调用单个索引的主体:

{
  "query": {
    "more_like_this": {
      "fields": [
        "Title",
        "Description"
      ],
      "like": {
        "_id": "62546841",
        "_index": "puppies",
        "_type": "puppies_little"
      }
    }
  }
}

...这是curl调用:
 curl -XPOST http://machineName:9200/puppies/_search?pretty=true -d

最佳答案

事实证明,要使此查询跨多个索引工作没有太多要做。我只需要将其他索引添加到http调用中。例如,使用curl:

curl -XPOST http://machineName:9200/puppies,kittens/_search?pretty=true -d '{ "query" : {  "more_like_this" : { "fields" : ["Title","Description"], "like" : { "_index" : "puppies", "_type":"puppies_little","_id":"62546841"} } } }'

10-06 01:29