[help|query not working ]elastic engineer 1|lesson 3-combining aggregations

I was trying the query mentioned in lesson3 of elastic engineer1.

I used the below query

GET blogs/_search
{
"size": 0,
"aggs": {
"author_bucket": {
"terms": {
"field": "author.keyword",
"size": 10
},
"aggs": {
"content_terms": {
"terms": {
"field": "content",
"size": 10
}
}
}
}
}
}

Then I was getting the below error

{
"error": {
"root_cause": [
{
"type": "illegal_argument_exception",
"reason": "Fielddata is disabled on text fields by default. Set fielddata=true on [content] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead."
}
],
"type": "search_phase_execution_exception",
"reason": "all shards failed",
"phase": "query",
"grouped": true,
"failed_shards": [
{
"shard": 0,
"index": "blogs",
"node": "eT9gth30Rbu2_90THEu0SQ",
"reason": {
"type": "illegal_argument_exception",
"reason": "Fielddata is disabled on text fields by default. Set fielddata=true on [content] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead."
}
}
],
"caused_by": {
"type": "illegal_argument_exception",
"reason": "Fielddata is disabled on text fields by default. Set fielddata=true on [content] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead.",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "Fielddata is disabled on text fields by default. Set fielddata=true on [content] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead."
}
}
},
"status": 400
}

** Could you please help to resolve this issue?**

Hello Manoj

you are referring to a code fragment presented in a lesson. This is about teaching concepts. What you are missing for this code fragment is the corresponding mapping.

You probably tried to replicate that code fragment with the same code, but against a different mapping.

Please check the mapping for field content. Is it possible that it is a multi-field made up of a field of type text and a field of type keyword? If so, then request a terms-aggregation for values in field content.keyword (as opposed to content).

Background info: for efficient execution aggregations rely on a data structure called doc-values, which is a columnar store made up of document ids along with the values stored in that field. This data structure is not available for fields of type text, this is why you are seeing this error reported.

Let me know if that answered your question.

Hello @manojb1-in.ibm.com

Di the answer make sense for you? Did you manage to run the example code with the suggested changes?

Best, Daniel

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