Options for storing field cache

Monitor the status of the field cache and set options for storing the cache on disk or on the heap.

The Solr field cache caches values for all indexed documents, which if left unchecked, can result in out-of-memory errors. For example, when performing faceted queries using multi-valued fields the multiValued fields are multi-segmented (as opposed to single segmented single-valued fields), resulting in an inefficient near real time (NRT) performance. You can use densely packed DocValue field types and per-segment docsets. Facet queries will be per-segment, which improves real-time search performance problems.

To ensure that the JVM heap can accommodate the cache, monitor the status of the field cache and take advantage of the Solr option for storing the cache on disk or on the heap. To view the status of the field cache memory usage, append &memory=true to the URL used to view the status of Solr cores. For example, to view the field cache memory usage of the DSE Search quick start example after running a few facet queries, use this URL:
http://localhost:8983/solr/admin/cores?action=STATUS&memory=true

Example 1

For example, the URL for viewing the field cache memory usage in JSON format and the output is:
http://localhost:8983/solr/admin/cores?action=STATUS&wt=json&indent=on&omitHeader=on
  &memory=true

. . .

  "memory":{
    "unInvertedFields":{
      "totalSize":0,
      "totalReadableSize":"0 bytes"},
    "multiSegment":{
      "multiSegment":"StandardDirectoryReader(segments_3:532:nrt _6p(4.6):
      C3193 _71(4.6):C161 _6i(4.6):C15 _6n(4.6):C21 _6e(4.6):C16 _6k(4.6):
      C19 _6t(4.6):C17 _6g(4.6):C10 _77(4.6):C12 _6v(4.6):C9 _7c(4.6):
      C66 _72(4.6):C14 _6x(4.6):C7 _6y(4.6):C7 _6w(4.6):C12)",
      "fieldCache":{
        "entriesCount":0},
      "totalSize":0,
      "totalReadableSize":"0 bytes"},
    "segments":{
      "_6p":{
        "segment":"_6p",
        "docValues":{
        . . .

        "fieldCache":{
          "entriesCount":0},
        "totalSize":51600,
        "totalReadableSize":"50.4 KB"}},
    "totalSize":619200,
    "totalReadableSize":"604.7 KB"}},
"totalMemSize":619200,
"totalReadableMemSize":"604.7 KB"}}

Example 2

After running a few sort by query functions, the output looks something like this:
. . .

      "fieldCache":{
        "entriesCount":1,
        "id":{
          "cacheType":"org.apache.lucene.index.SortedDocValues",
          "size":260984,
          "readableSize":"254.9 KB"}},
      "totalSize":260984,
      "totalReadableSize":"254.9 KB"},
    "segments":{

. . .

        "fieldCache":{
          "entriesCount":2,
          "age":{
            "cacheType":"int",
            "size":3832,
            "readableSize":"3.7 KB"},
          "id":{
            "cacheType":"int",
            "size":3832,
            "readableSize":"3.7 KB"}},
        "totalSize":59232,
        "totalReadableSize":"57.8 KB"}},
    "totalSize":524648,
    "totalReadableSize":"512.4 KB"}},
"totalMemSize":524648,
"totalReadableMemSize":"512.4 KB"}}

Using the field cache

In Lucene-Solr 4.5 and later, docValues are mostly disk-based to avoid the requirement for large heap allocations in Solr. If you use the field cache in sort, stats, and other queries, make those fields docValues.