Go4*_*4It 15 search post get elasticsearch
根据ES文档,这2个搜索请求应该得到相同的结果:
得到
http://localhost:9200/app/users/_search?source={"query": {"term": {"email":"foo@gmail.com"}}}
Run Code Online (Sandbox Code Playgroud)
POST
http://localhost:9200/app/users/_search
Run Code Online (Sandbox Code Playgroud)
邮政机构:
{
"query": {
"term": {
"email":"foo@gmail.com"
}
}
}
Run Code Online (Sandbox Code Playgroud)
但是第一个没有给出结果,而第二个给了我预期的结果.我使用ES版本0.19.10其他人有相同的行为吗?这是一个错误吗?
And*_*ret 24
source根据http://www.elasticsearch.org/guide/reference/api/search/uri-request/,它不是有效的查询字符串参数
Elasticsearch允许三种方式执行搜索请求......
GET请求正文:
curl -XGET "http://localhost:9200/app/users/_search" -d '{
"query": {
"term": {
"email": "foo@gmail.com"
}
}
}'
Run Code Online (Sandbox Code Playgroud)
POST请求正文:
由于并非所有客户端都支持使用正文GET,因此也允许使用POST.
curl -XPOST "http://localhost:9200/app/users/_search" -d '{
"query": {
"term": {
"email": "foo@gmail.com"
}
}
}'
Run Code Online (Sandbox Code Playgroud)
GET没有请求正文:
curl -XGET "http://localhost:9200/app/users/_search?q=email:foo@gmail.com"
Run Code Online (Sandbox Code Playgroud)
或(如果您想手动对您的查询字符串进行URL编码)
curl -XGET "http://localhost:9200/app/users/_search?q=email%3Afoo%40gmail.com"
Run Code Online (Sandbox Code Playgroud)
在第一种情况下,您应该对查询进行 URL 编码:
http://localhost:9200/app/users/_search?source=%7b%22query%22%3a+%7b%22term%22%3a+%7b%22email%22%3a%22foo%40gmail.com%22%7d%7d%7d
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
21078 次 |
| 最近记录: |