如何使用 ElasticSearch 和 CURL 请求在多个字段中进行搜索?
How do I search in multiple fields with ElasticSearch and a CURL request?
如何使用 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
有什么提示吗?
谢谢。
URI 中的参数必须是 urlencoded,并且不应包含转义双引号。
例如 OP 中的查询应该是:
curl -XGET 'http://localhost:9200/foo/_count?q=user%3Afoo%20AND%20posts%3Abar&pretty=true
如何使用 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
有什么提示吗?
谢谢。
URI 中的参数必须是 urlencoded,并且不应包含转义双引号。
例如 OP 中的查询应该是:
curl -XGET 'http://localhost:9200/foo/_count?q=user%3Afoo%20AND%20posts%3Abar&pretty=true