如何使用ElasticSearch和CURL请求在多个字段中进行搜索?

时间:2015-09-15 14:30:42

标签: search elasticsearch field

如何使用curl -X GET请求在多个字段上执行ElasticSearch搜索?

以下是我尝试过的一个例子:

 curl -XGET "http://localhost:9200/foo/_count?pretty=true&q=user:foo AND posts:bar"

此外:

curl -XGET 'http://localhost:9200/foo/_count?q=\"user:foo AND posts:bar\"&pretty=true'

问题是,我似乎只得到了这个回应:

curl: (52) Empty reply from server

任何提示?

感谢。

1 个答案:

答案 0 :(得分:1)

URI中的参数需要为urlencoded,不应包含转义的双引号。

例如,OP中的查询应为:

curl -XGET 'http://localhost:9200/foo/_count?q=user%3Afoo%20AND%20posts%3Abar&pretty=true