Elasticsearch aggregation not hits

I want to use aggregation to statistic how many types in my data ,but failed with command , the command hits nothing

GET /_search
     {
      "size": 0,
      "aggs": {
        "aggs_name": {
          "terms": {
            "field": "type"
          }
        }
      }
    }

and my data is like this:

 {

    "_index": "indexname",

    "_type": "doc",

    "_id": "",

    "_version": 1,

    "_score": 1,

    "_source": {

    "type":"type_A"

    }
    }

have I missed something necessary ?

What is the error message?

actually there are no error through the elasticsearch header ,here are the results

{

  • "took": 3,
  • "timed_out": false,
  • "_shards": {
    • "total": 35,
    • "successful": 35,
    • "skipped": 0,
    • "failed": 0},
  • "hits": {
    • "total": 0,
    • "max_score": null,
    • "hits": }

}

I execute the command via elasticsearch header, here are the result

{
"took": 25,
"timed_out": false,
"_shards": {
"total": 35,
"successful": 30,
"skipped": 0,
"failed": 5,
"failures": [
{
"shard": 0,
"index": "indexname",
"node": "61impylyQ2iHT_KPVZ2kig",
"reason": {
"type": "illegal_argument_exception",
"reason": "Fielddata is disabled on text fields by default. Set fielddata=true on [D010010] 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."
}
}
]
},
"hits": {
"total": 0,
"max_score": 0,
"hits":
},
"aggregations": {
"aggs_name": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets":
}
}
}

You need to change the mapping for the field type to keyword if you want to compute aggregations.
If you are using default mapping, try to run the agg on type.keyword instead.

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