_cat/fielddata api request doesn't return any data

Hi, I am testing OS1.3.1 REST API and am trying to collect fielddata. Have enabled fielddata cache in opensearch.yml file: “indices.fielddata.cache.size: 100MB”, and have also established the mapping like so:

curl -XPUT -u 'admin:admin' --insecure 'https://localhost:9200/my-index/_mapping' -H 'Content-Type: application/json' -d '{"properties":{"Description":{"type":"text","fielddata":true}}}'

However, when I request fielddata, the request is successful but it doesn’t return any data:

curl -XGET -u 'admin:admin' --insecure -XGET https://localhost:9200/_cat/fielddata?v
id host ip node field size

How can I check whether the fielddata is correctly populated?

Hi @fmanimali ,

The field data cache is not populated if not needed / used. Generally, the purpose of field data is [1]:

… if you try to sort, aggregate, or access values from a script on a text field …

So in you particular example, when you trigger the aggregation on the description property (whenever it makes sense or not), you will see field data cache populated:

POST https://localhost:9200/my-index/_search

  "aggs": {
    "description": {
      "terms": { "field": "description" }

When you run the /_cat/fielddata after aggregation, you should see stats.
Hope it helps.

[1] Text type family | Elasticsearch Guide [master] | Elastic