PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, October 25, 2022

[FIXED] How to get multiple values output from multiple fields with one _search request?

 October 25, 2022     elasticsearch, elasticsearch-dsl     No comments   

Issue

On a performance testing project where ELK stack is used to collect and process API test data streams(samples/document go under one index) it would be good if we could get multiple aggregated results with only one _search request, like the count of successful requests AND average response time AND various percentiles, etc. Is it possible to create such a DSL query or do we have to execute multiple searches like one to get the count of successful requests, another one for percentiles, etc?


Solution

you sure can, this page of the documentation gives an example, but here it is for reference;

curl -X GET "localhost:9200/my-index-000001/_search?pretty" -H 'Content-Type: application/json' -d'
{
  "aggs": {
    "my-first-agg-name": {
      "terms": {
        "field": "my-field"
      }
    },
    "my-second-agg-name": {
      "avg": {
        "field": "my-other-field"
      }
    }
  }
}
'


Answered By - warkolm
Answer Checked By - Terry (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing