0

I'm trying perform an elasticsearch query as a GET request in order pull data from the index which I created. The data which is in the index is, a table from MySQL DB, configured though logstash.

Here is my request without the IN clause:

http://localhost:9200/response_summary/_search?q=api:"location"+AND+transactionoperationstatus:"charged"+AND+operatorid='DIALOG'+AND+userid:test+AND+time:"2015-05-27"

In the above, I should be able to append sum(chargeAmount+0) & group by . I tried giving it a search on the web, but couldn't find any solutions.

Any help could be appreaciated.

4

1 に答える 1

1

クエリの の後に置くものはすべてq=...query と同じ構文を使用するため、query_stringクエリを書き直して、query_string集計を利用および使用して目的の合計を計算できます。

curl -XPOST http://localhost:9200/response_summary/_search -d '{
   "query": {
       "query_string": {
           "query": "api:\"location\" AND transactionoperationstatus:\"charged\" AND operatorid:\"DIALOG\" AND userid:test AND time:\"2015-05-27\" AND responseCode:(401 403)"
       }
   },
   "aggs": {
      "total": {
          "terms": {
              "field": "chargeAmount"
          },
          "aggs":{
             "total": {
                "sum": {
                    "field": "chargeAmount"
                }
             }
          }
      }
   }
}'

Postman では、次のようになります。

ここに画像の説明を入力

于 2016-09-29T08:41:56.183 に答える