[英]Elastic search querying using rest
I am trying to execute below query in elastic search using rest call which is not providing aggregation results.But if i excute the same query in elasticsearch browser it provides aggregation results. 我正在尝试使用不提供聚合结果的rest调用在弹性搜索中执行以下查询。但是如果我在Elasticsearch浏览器中执行相同的查询,它将提供聚合结果。
Query: 查询:
{ "aggregations": { "by_salary": { "terms": { "field": "salary" } } } }
Rest call: 休息电话:
http://localhost:9200/tcx_transaction/_search?query={ "aggregations": { "by_salary": { "terms": { "field": "salary" } } } }
Results: 结果:
"aggregations": {
"by_salary": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "manager",
"doc_count": 39420
}
,
{
"key": "developer",
"doc_count": 13140
}
,
{
"key": "HR",
"doc_count": 4380
}
]
}
}
You are misusing the REST interface. 您正在滥用REST接口。 Take a peek at the parameters allowed for URI searching . 窥视允许URI搜索的参数 。 query
isn't one of them. query
不是其中之一。 q
is but that is specifically for a very special type of query . q
是,但是它专门用于非常特殊的查询类型 。
As pickypg mentioned, what you have set to query
should be part of the HTTP POST body. 正如pickypg提到的,您要设置的query
应该是HTTP POST正文的一部分。
try installing "curl" and then, from shell: 尝试安装“ curl”,然后从外壳中安装:
curl -XPOST 'http://localhost:9200/tcx_transaction/_search' -d
'{ "aggregations": { "by_salary": { "terms": { "field": "salary" } } } }'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.