Not able to run aggregation query.
This is what I am doing:
1)Mapping creation:
curl -XPUT 'localhost:9200/items?pretty' -H 'Content-Type: application/json' -d'
{
"mappings": {
"item": {
"properties": {
"number": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword"
}
}
}
}
}
}
}
'
2)Inserting index:
curl -XPUT 'http://localhost:9200/items/item/i1' -d '{ "number" : 1001}'
3)Aggregation query:
curl -XPOST 'localhost:9200/items/_search?size=0&pretty' -H 'Content-Type: application/json' -d'
{
"aggs" : {
"number" : { "max" : { "field" : "number" } }
}
}
'
Error:
Fielddata is disabled on text fields by default. Set fielddata=true on [number] 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."