简体   繁体   English

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

[英]How do I search in multiple fields with ElasticSearch and a CURL request?

How can I perform a ElasticSearch search on multiple fields, using a curl -X GET request? 如何使用curl -X GET请求在多个字段上执行ElasticSearch搜索?

Here's an example of what I've tried: 这是我尝试过的示例:

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

Also: 也:

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

Problem is, I only seem to get this response: 问题是,我似乎只得到以下响应:

curl: (52) Empty reply from server

Any hints? 有什么提示吗?

Thanks. 谢谢。

The params in the URI need to be urlencoded and should not include the escaped double quotes. URI中的参数需要使用urlencode编码,并且不应包含转义的双引号。

For example the query in OP should be : 例如,OP中的查询应为:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM