# Fielddata cache shows nothing

**URL:** https://discuss.elastic.co/t/fielddata-cache-shows-nothing/74970
**Category:** Elasticsearch
**Created:** [February 14, 2017, 6:56am UTC](https://discuss.elastic.co/t/fielddata-cache-shows-nothing/74970 "2017-02-14T06:56:59Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Alex\_Davidovich](https://avatars.discourse-cdn.com/v4/letter/a/b9e5f3/32.png) [@Alex\_Davidovich](https://discuss.elastic.co/u/Alex_Davidovich)
#### Post date: [February 14, 2017, 6:56am UTC](https://discuss.elastic.co/t/fielddata-cache-shows-nothing/74970/1 "2017-02-14T06:56:59Z")

</div>

Our goal is to find out how to reduce memory consumption of elasticsearch and for that I checked  
our use of fielddata cache.  
I understand that fielddata cache is used to store aggregations and sorting results.  
In my application we use sorting very much and not so much aggregation queries.  
I ran this query:

```
GET /events/_search
{
    "sort" : 
        { "timestamp" : {"order" : "asc"}}
}  

```

and this query

```
GET /events/_search
{
    "sort" : 
        { "id" : {"order" : "asc"}}
        , "size": 1000     
}

```

and got results.

After that I checked the fielddata cache and got

```
{
   "_shards": {
      "total": 3,
      "successful": 3,
      "failed": 0
   },
   "_all": {
      "primaries": {
         "fielddata": {
            "memory_size_in_bytes": 0,
            "evictions": 0,
            "fields": {
               "_parent": {
                  "memory_size_in_bytes": 0
               }
            }
         }
      },
      "total": {
         "fielddata": {
            "memory_size_in_bytes": 0,
            "evictions": 0,
            "fields": {
               "_parent": {
                  "memory_size_in_bytes": 0
               }
            }
         }
      }
   },
   "indices": {
      "events": {
         "primaries": {
            "fielddata": {
               "memory_size_in_bytes": 0,
               "evictions": 0,
               "fields": {
                  "_parent": {
                     "memory_size_in_bytes": 0
                  }
               }
            }
         },
         "total": {
            "fielddata": {
               "memory_size_in_bytes": 0,
               "evictions": 0,
               "fields": {
                  "_parent": {
                     "memory_size_in_bytes": 0
                  }
               }
            }
         }
      }
   }
}

```

So fielddata cache is not used? Why is that?

Thank you

---

<div class="post-metadata">

### Author: ![tanguy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tanguy/32/6030_2.png) [@tanguy](https://discuss.elastic.co/u/tanguy)
#### Post date: [February 14, 2017, 9:59am UTC](https://discuss.elastic.co/t/fielddata-cache-shows-nothing/74970/2 "2017-02-14T09:59:04Z")

</div>

Hi,

What version do you use?

> [@Alex\_Davidovich](#):
>
> I understand that fielddata cache is used to store aggregations and sorting results.

Actually, fieldata is a data structure that basically maps a document's field with its values, so that it's easy to access all field values once you know the document and the field name. This is used internally to compute aggregations (but not to store them) and also to sort search hits.

There's another feature that is used when computing aggs and sorting docs: doc values. It's a more efficient disk based data structure for similar usage. It can be used with most field types but not `text`. Elasticsearch (in the recent versions) will always prefer to use doc values for things like sorting, and that can explain why fielddata is not used in your example (I support `id` is of type keyword and `timstamp` is a date or long)

---

<div class="post-metadata">

### Author: ![Alex\_Davidovich](https://avatars.discourse-cdn.com/v4/letter/a/b9e5f3/32.png) [@Alex\_Davidovich](https://discuss.elastic.co/u/Alex_Davidovich)
#### Post date: [February 14, 2017, 2:43pm UTC](https://discuss.elastic.co/t/fielddata-cache-shows-nothing/74970/3 "2017-02-14T14:43:59Z")

</div>

Thank you for your answer. I am running elasticsearch 5.0.0.  
I want to understand which structures in elasticsearch are consuming memory in order to try  
and configure them in a way that I could allocate less heap size.  
All my caches seems almost empty when I look at the node stats, but still 38% of heap is used.  
Can you please help me understand this?

```
"D1_QIMfUSoiIKAMwWfNTpA": {
         "indices": {
            "docs": {
               "count": 1707940,
               "deleted": 13
            },
            "store": {
               "size_in_bytes": 111575525,
               "throttle_time_in_millis": 0
            },
            "indexing": {
               "index_total": 4007,
               "index_time_in_millis": 665,
               "index_current": 0,
               "index_failed": 0,
               "delete_total": 7,
               "delete_time_in_millis": 7,
               "delete_current": 0,
               "noop_update_total": 1,
               "is_throttled": false,
               "throttle_time_in_millis": 0
            },
             "merges": {
               "current": 0,
               "current_docs": 0,
               "current_size_in_bytes": 0,
               "total": 1,
               "total_time_in_millis": 1440,
               "total_docs": 28359,
               "total_size_in_bytes": 1897215,
               "total_stopped_time_in_millis": 0,
               "total_throttled_time_in_millis": 0,
               "total_auto_throttle_in_bytes": 20971520
            },
            "refresh": {
               "total": 6,
               "total_time_in_millis": 218
            },
            "flush": {
               "total": 28,
               "total_time_in_millis": 1296
            },
            "warmer": {
               "current": 0,
               "total": 29,
               "total_time_in_millis": 51
            },
            "query_cache": {
               "memory_size_in_bytes": 0,
               "total_count": 33,
               "hit_count": 0,
               "miss_count": 33,
               "cache_size": 0,
               "cache_count": 0,
               "evictions": 0
            },
            "fielddata": {
               "memory_size_in_bytes": 0,
               "evictions": 0
            },
            "completion": {
               "size_in_bytes": 0
            },
            "segments": {
               "count": 13,
               "memory_in_bytes": 752545,
               "terms_memory_in_bytes": 510448,
               "stored_fields_memory_in_bytes": 92040,
               "term_vectors_memory_in_bytes": 0,
               "norms_memory_in_bytes": 6656,
               "points_memory_in_bytes": 142205,
               "doc_values_memory_in_bytes": 1196,
               "index_writer_memory_in_bytes": 0,
               "version_map_memory_in_bytes": 0,
               "fixed_bit_set_memory_in_bytes": 0,
               "max_unsafe_auto_id_timestamp": -1,
               "file_sizes": {}
            },
            "translog": {
               "operations": 0,
               "size_in_bytes": 43
            },
            "request_cache": {
               "memory_size_in_bytes": 0,
               "evictions": 0,
               "hit_count": 0,
               "miss_count": 0
            },
            "recovery": {
               "current_as_source": 0,
               "current_as_target": 0,
               "throttle_time_in_millis": 12
            }
         },
         "os": {
            "timestamp": 1487082930237,
            "cpu": {
               "percent": 2,
               "load_average": {
                  "1m": 1.15,
                  "5m": 0.92,
                  "15m": 0.81
               }
            },
            "mem": {
               "total_in_bytes": 53436141568,
               "free_in_bytes": 3483336704,
               "used_in_bytes": 49952804864,
               "free_percent": 7,
               "used_percent": 93
            },
            "swap": {
               "total_in_bytes": 0,
               "free_in_bytes": 0,
               "used_in_bytes": 0
            }
         },
         "process": {
            "timestamp": 1487082930237,
            "open_file_descriptors": 202,
            "max_file_descriptors": 65536,
            "cpu": {
               "percent": 0,
               "total_in_millis": 22880
            },
            "mem": {
               "total_virtual_in_bytes": 3261501440
            }
         },
         "jvm": {
            "timestamp": 1487082930238,
            "uptime_in_millis": 46726,
            "mem": {
               "heap_used_in_bytes": 200369872,
               "heap_used_percent": 38,
               "heap_committed_in_bytes": 519438336,
               "heap_max_in_bytes": 519438336,
               "non_heap_used_in_bytes": 76521080,
               "non_heap_committed_in_bytes": 81330176,
               "pools": {
                  "young": {
                     "used_in_bytes": 99732776,
                     "max_in_bytes": 139591680,
                     "peak_used_in_bytes": 139591680,
                     "peak_max_in_bytes": 139591680
                  },
                  "survivor": {
                     "used_in_bytes": 6763448,
                     "max_in_bytes": 17432576,
                     "peak_used_in_bytes": 17432568,
                     "peak_max_in_bytes": 17432576
                  },
                  "old": {
                     "used_in_bytes": 93873648,
                     "max_in_bytes": 362414080,
                     "peak_used_in_bytes": 93873648,
                     "peak_max_in_bytes": 362414080
                  }
               }
            },
            "buffer_pools": {
               "direct": {
                  "count": 30,
                  "used_in_bytes": 71406353,
                  "total_capacity_in_bytes": 71406352
               },
               "mapped": {
                  "count": 31,
                  "used_in_bytes": 110824445,
                  "total_capacity_in_bytes": 110824445
               }
            }
```

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [March 14, 2017, 2:45pm UTC](https://discuss.elastic.co/t/fielddata-cache-shows-nothing/74970/4 "2017-03-14T14:45:08Z")

</div>

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