ElasticSearch中的多搜索无法正常工作

时间:2017-03-07 10:35:42

标签: elasticsearch

我正在尝试使用 elasticsearch Multi Search API

我的requests文件如下所示:

$ cat requests 
{"index" : "indexA"}
{"query" : {"match_all" : {}}, "from" : 0, "size" : 2}
{"index" : "indexB"}
{"query" : {"match_all" : {}}, "from" : 0, "size" : 2}

我正在使用以下curl request

curl -XGET localhost:9200/_msearch --data-binary @requests

使用此请求,我只会从indexA内的response array获取内容。 indexB的内容完全被忽略。我在这里做错了什么?

1 个答案:

答案 0 :(得分:1)

当您运行cat请求时,只需在最后一行之后添加一个新行,然后再按Ctrl + C。

$ cat requests 
{"index" : "indexA"}
{"query" : {"match_all" : {}}, "from" : 0, "size" : 2}
{"index" : "indexB"}
{"query" : {"match_all" : {}}, "from" : 0, "size" : 2}
          <--- add a new line here

然后它会起作用。

相关问题