Aggregation-keywords


(Raghunadhan) #1

Dear All,

What does term and keyword mean that are used in aggregation query,

Please find the example below

GET /bank/_search
{
"size": 0,
"aggs": {
"group_by_state": {
"terms": {
"field": "state.keyword"
},
"aggs": {
"average_balance": {
"avg": {
"field": "balance"
}
}
}
}
}
}


(David Pilato) #2

I guess you meant terms and state.keyword.

If you are not defining any mapping in elasticsearch, then elasticsearch tries to automatically guess the mapping for you. If you sent a text within a state field, then elasticsearch created 2 fields behind the scene state and state.keyword. The former is more for full text search, the later more for computing aggregations, do sorting...

You can look at the mapping by doing:

GET /bank/_mapping

(Raghunadhan) #3

what does that multi-bucket value source based aggregation mean ,i don't understand
terms : that's a terms aggregation,bucket.And in some cases we done use state.keyword why its is .Please explain.I just now started to learn elasticsearch


(David Pilato) #4

I don't understand the question.

Could you provide a full recreation script as described in About the Elasticsearch category. It will help to better understand what you are doing. Please, try to keep the example as simple as possible.

Then from that tell me what you don't understand.


(Raghunadhan) #5

What does 'terms' and 'keyword' mean used in aggregation script for example see below example.And then don't understand the concept given in the above link given b you

GET /bank/_search
{
"size": 0,
"aggs": {
"group_by_state": {
"terms": {
"field": "state.keyword"
},
"aggs": {
"average_balance": {
"avg": {
"field": "balance"
}
}
}
}
}
}


(David Pilato) #6

I already answered to this question here: Aggregation-keywords

I don't understand what you don't understand in my answer.

May be someone else understand what the problem is?


(Raghunadhan) #7

When should we use aggregation keyword


(David Pilato) #8

There's no keyword aggregation if this is what you meant.

You need to run aggregation on fields which have a keyword datatype.


(Emma543) #9

Thank You so much for this post... psiphon


(Raghunadhan) #10

Dear David.

state.keyword in this "state" is a field and why does we use "keyword" word that is as
field.keyword


(David Pilato) #11

In case you missed what I explained earlier:

If you are not defining any mapping in elasticsearch, then elasticsearch tries to automatically guess the mapping for you. If you sent a text within a state field, then elasticsearch created 2 fields behind the scene state and state.keyword . The former is more for full text search, the later more for computing aggregations, do sorting...

You can look at the mapping by doing:

GET /bank/_mapping

(system) closed #12

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.