Questions tagged [elasticsearch-aggregation]
1111 questions
29
votes
5 answers
ElasticSearch - How to display an additional field name in aggregation query
How can I add a new key called 'agency_name' in my output bucket.
I am running an aggregation code as shown below
{
"aggs": {
"name": {
"terms": {
"field": "agency_code"
}
}
}
}
I will be getting the out put…

Amal Kumar S
- 15,555
- 19
- 56
- 88
15
votes
1 answer
Diversified results on Elasticsearch search
I've done a complex query using the popularity to improve the results of social media documents using Elasticsearch.
The query works really fine and the top results are always centered on the query and with interesting elements.
However it has a…

David Mabodo
- 745
- 5
- 16
13
votes
1 answer
Fuzzy Bucket Aggregation in Elasticsearch
Elasticsearch supports fuzzy search queries: https://www.elastic.co/guide/en/elasticsearch/guide/2.x/fuzzy-match-query.html
And Bucket Aggregation by Term:…

dsromind
- 131
- 3
13
votes
1 answer
How to perform a pipeline aggregation without returning all buckets in Elasticsearch
I'm using Elasticsearch 2.3 and I'm trying to perform a two-step computation using a pipeline aggregation.
I'm only interested in the final result of my pipeline aggregation but Elasticsearch returns all the buckets information.
Since I have a huge…

jrjd
- 455
- 4
- 9
10
votes
1 answer
Insert aggregation results into an index
The goal is to build an Elasticsearch index with only the most recent documents in groups of related documents to track the current state of some monitoring counters and states.
I have crafted a simple Elasticsearch aggregation query:
{
"size":…

Pragmateek
- 13,174
- 9
- 74
- 108
10
votes
0 answers
Elasticsearch aggregations multifaceted navigation, excluding facets by group
I'm pretty new to ES and have been trying to implement faceted navigation in the same way most of the large e-commerce stores do.
Part of my products mapping looks like this:
'name' => [
'type' => 'string',
'analyzer' =>…

user3653478
- 101
- 3
9
votes
1 answer
Control number of buckets created in an aggregation
In Elasticsearch there's a limit on how many buckets you can create in an aggregation. If it creates more buckets than the specified limit, you will get a warning message In ES 6.x and an error will be thrown in future versions.
Here's the warning…

Ahmad Mozafarnia
- 151
- 1
- 1
- 8
9
votes
1 answer
How to return actual value (not lowercase) when performing search with terms aggregation?
I am working on an ElasticSearch (6.2) project where the index has many keyword fields and they are normalized with lowercase filter for performing case-insensitive searches. The search working great and returning actual values (not lowercase) of…

Anam
- 11,999
- 9
- 49
- 63
9
votes
1 answer
Group by date and category elasticsearch query
I have a index in elasticsearch and have imported below json file:
{"index" : {"_id": "1"}}
{"Name": "apple","Type": "fruit","Rate": "64","Date": "2016-01-24"}
{"index" : {"_id": "2"}}`enter code here`
{"Name": "grape","Type": "fruit","Rate":…

Vaibhav
- 303
- 1
- 3
- 9
8
votes
1 answer
Aggregate and filter from one index to another through a third
On my Elasticsearch server I have three indices: Person, Archive and Document.
Each document has a archive field which is the _id of the Archive it is in.
Each archive has a owner which is the _id of the Person that is the owner of the…

Oskar Persson
- 6,605
- 15
- 63
- 124
8
votes
2 answers
Elasticsearch SQL like subquery aggregation
I am playing around with ES to understand if it can cover most of my scenarios.
I am at the point where I am stuck thinking how to reach a certain results that is pretty simple in SQL.
This is the example
In elastic I have an index with this…

Simone Belia
- 253
- 3
- 10
8
votes
4 answers
Limiting aggreation to the top X hits in elasticsearch
ElasticSearch builds the aggregation results based on all the hits of the query independently of the from and size parameters. This is what we want in most cases, but I have a particular case in which I need to limit the aggregation to the top N…

b_habegger
- 309
- 2
- 13
8
votes
2 answers
Elasticsearch Aggregation Query with multiple excludes
I have a bunch of company data in an ES database. I am looking to pull counts of how many documents each company occurs in, but I'm having some problems with the aggregation query. I am looking to exclude terms such as "Corporation" or "Inc." Thus…

drowningincode
- 1,115
- 1
- 12
- 19
7
votes
1 answer
Filtering, sorting and paginating by sub-aggregations in ElasticSearch 6
I have a collection of documents, where each document indicates the available rooms for a given hotel and day, and their cost for that day:
{
"hotel_id": 2016021519381313,
"day": "20200530",
"rooms": [
…

Vlad
- 802
- 1
- 10
- 23
7
votes
1 answer
How to get specific _source fields in aggregation
I am exploring ElasticSearch, to be used in an application, which will handle large volumes of data and generate some statistical results over them. My requirement is to retrieve certain statistics for a particular field. For example, for a given…

Poonam Anthony
- 1,848
- 3
- 17
- 27