ElasticSearch POST with json search body vs GET with json in url [英] ElasticSearch POST with json search body vs GET with json in url
问题描述
根据ES文档,这2个搜索请求应该得到相同的结果:
According to the ES documentation, those 2 search request should get the same results:
GET
http://localhost:9200/app/users/_search?source={"query": {"term": {"email":"foo@gmail.com"}}}
POST
http://localhost:9200/app/users/_search
发布正文: / p>
Post body :
{
"query": {
"term": {
"email":"foo@gmail.com"
}
}
}
但是第一个没有结果,而第二个给我预期的结果。我使用ES版本0.19.10
有没有人有相同的行为?这是一个错误?
But the first one gives no result while the second one gives me the expected result. I use ES version 0.19.10 Did anybody else have the same behavior ? Is this a bug ?
推荐答案
源
不是有效的查询字符串参照 http://www.elasticsearch.org/guide/reference/api/search/ uri-request /
source
is not a valid query string argument according to http://www.elasticsearch.org/guide/reference/api/search/uri-request/
弹性搜索允许三种方式执行搜索请求...
Elasticsearch allows three ways to perform a search request...
GET请求正文:
curl -XGET "http://localhost:9200/app/users/_search" -d '{
"query": {
"term": {
"email": "foo@gmail.com"
}
}
}'
POST与请求正文:
curl -XPOST "http://localhost:9200/app/users/_search" -d '{
"query": {
"term": {
"email": "foo@gmail.com"
}
}
}'
GET无请求正文:
curl -XGET "http://localhost:9200/app/users/_search?q=email:foo@gmail.com"
或(如果你想手动地对您的查询字符串进行编码)
or (if you want to manually URL encode your query string)
curl -XGET "http://localhost:9200/app/users/_search?q=email%3Afoo%40gmail.com"
这篇关于ElasticSearch POST with json search body vs GET with json in url的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!