简体   繁体   English

使用Rest进行弹性搜索查询

[英]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.

相关问题 弹性搜索查询 - elastic search query querying 基于_source字段搜索的弹性搜索 - Querying elastic search based on _source fields searching 弹性搜索:使用弹性搜索 API 生成弹性搜索查询 - Elastic Search: Generating Elastic Search query using Elastic search API 如何通过 Java 高级 rest 客户端在 Elastic Search 中使用多个字段进行搜索 - How to search using multiple fields in Elastic Search through Java high level rest client 在现有的Rest服务中配置Elastic Search - Configure Elastic Search in already existing rest service Java Rest弹性搜索JSON文档 - Java rest elastic search json documents 弹性搜索 如果使用低级 Rest Client 对特定数据库列进行了任何更改,如何检索数据 - Elastic Search How to retrieve the data if any changes made to a particular database column using Low Level Rest Client 使用 Rest 高级客户端检索或插入数据到 Elastic Search 时出现 SocketTimeoutException - SocketTimeoutException while retrieving or inserting data into Elastic Search by using Rest High Level Client 弹性搜索,通过Rest Java Client使用源和设置创建索引 - Elastic Search, creating index with sources and settings by Rest Java Client 弹性搜索:将客户端传输到高级其余客户端 - Elastic Search: Transport Client to High Level Rest Client
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM