<p dir="auto"><strong>Elasticsearch version</strong>:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="# elasticsearch --version
Version: 2.2.0, Build: 8ff36d1/2016-01-27T13:32:39Z, JVM: 1.8.0_72-internal"><pre class="notranslate"><code class="notranslate"># elasticsearch --version
Version: 2.2.0, Build: 8ff36d1/2016-01-27T13:32:39Z, JVM: 1.8.0_72-internal
</code></pre></div>
<p dir="auto"><strong>JVM version</strong>:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="# java -version
openjdk version &quot;1.8.0_72-internal&quot;
OpenJDK Runtime Environment (build 1.8.0_72-internal-b15)
OpenJDK 64-Bit Server VM (build 25.72-b15, mixed mode)"><pre class="notranslate"><code class="notranslate"># java -version
openjdk version "1.8.0_72-internal"
OpenJDK Runtime Environment (build 1.8.0_72-internal-b15)
OpenJDK 64-Bit Server VM (build 25.72-b15, mixed mode)
</code></pre></div>
<p dir="auto"><strong>OS version</strong>: Debian Jessie on kernel 4.1.3.</p>
<p dir="auto"><strong>Description of the problem including expected versus actual behavior</strong>:</p>
<p dir="auto">Elasticsearch reports fielddata memory for <code class="notranslate">doc_values</code> only index:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="index                   fm   fcm    sm
raytracer-2016.03.31 6.5gb 2.5gb 4.6gb"><pre class="notranslate"><code class="notranslate">index                   fm   fcm    sm
raytracer-2016.03.31 6.5gb 2.5gb 4.6gb
</code></pre></div>
<p dir="auto">Index mapping declares everything to be <code class="notranslate">doc_values</code> (and it should be default in 2.2 anyway):</p>
<div class="highlight highlight-source-json notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="{
  &quot;template&quot;: &quot;raytracer-*&quot;,
  &quot;settings&quot;: {
    &quot;number_of_shards&quot;: 50,
    &quot;number_of_replicas&quot;: 1,
    &quot;index.refresh_interval&quot;: &quot;30s&quot;,
    &quot;index.query.default_field&quot;: &quot;id&quot;
  },
  &quot;mappings&quot;: {
    &quot;_default_&quot;: {
      &quot;_all&quot;: {
        &quot;enabled&quot;: false
      },
      &quot;dynamic_templates&quot;: [
        {
          &quot;string_fields&quot;: {
            &quot;match&quot;: &quot;*&quot;,
            &quot;match_mapping_type&quot;: &quot;string&quot;,
            &quot;mapping&quot;: {
              &quot;type&quot;: &quot;string&quot;,
              &quot;index&quot;: &quot;not_analyzed&quot;,
              &quot;ignore_above&quot;: 256,
              &quot;doc_values&quot;: true
            }
          }
        },
        {
          &quot;long_fields&quot;: {
            &quot;match&quot;: &quot;*&quot;,
            &quot;match_mapping_type&quot;: &quot;long&quot;,
            &quot;mapping&quot;: {
              &quot;type&quot;: &quot;long&quot;,
              &quot;doc_values&quot;: true
            }
          }
        },
        {
          &quot;double_fields&quot;: {
            &quot;match&quot;: &quot;*&quot;,
            &quot;match_mapping_type&quot;: &quot;double&quot;,
            &quot;mapping&quot;: {
              &quot;type&quot;: &quot;double&quot;,
              &quot;doc_values&quot;: true
            }
          }
        },
        {
          &quot;date_fields&quot;: {
            &quot;match&quot;: &quot;*&quot;,
            &quot;match_mapping_type&quot;: &quot;date&quot;,
            &quot;mapping&quot;: {
              &quot;type&quot;: &quot;date&quot;,
              &quot;doc_values&quot;: true
            }
          }
        }
      ]
    }
  }
}"><pre class="notranslate">{
  <span class="pl-ent">"template"</span>: <span class="pl-s"><span class="pl-pds">"</span>raytracer-*<span class="pl-pds">"</span></span>,
  <span class="pl-ent">"settings"</span>: {
    <span class="pl-ent">"number_of_shards"</span>: <span class="pl-c1">50</span>,
    <span class="pl-ent">"number_of_replicas"</span>: <span class="pl-c1">1</span>,
    <span class="pl-ent">"index.refresh_interval"</span>: <span class="pl-s"><span class="pl-pds">"</span>30s<span class="pl-pds">"</span></span>,
    <span class="pl-ent">"index.query.default_field"</span>: <span class="pl-s"><span class="pl-pds">"</span>id<span class="pl-pds">"</span></span>
  },
  <span class="pl-ent">"mappings"</span>: {
    <span class="pl-ent">"_default_"</span>: {
      <span class="pl-ent">"_all"</span>: {
        <span class="pl-ent">"enabled"</span>: <span class="pl-c1">false</span>
      },
      <span class="pl-ent">"dynamic_templates"</span>: [
        {
          <span class="pl-ent">"string_fields"</span>: {
            <span class="pl-ent">"match"</span>: <span class="pl-s"><span class="pl-pds">"</span>*<span class="pl-pds">"</span></span>,
            <span class="pl-ent">"match_mapping_type"</span>: <span class="pl-s"><span class="pl-pds">"</span>string<span class="pl-pds">"</span></span>,
            <span class="pl-ent">"mapping"</span>: {
              <span class="pl-ent">"type"</span>: <span class="pl-s"><span class="pl-pds">"</span>string<span class="pl-pds">"</span></span>,
              <span class="pl-ent">"index"</span>: <span class="pl-s"><span class="pl-pds">"</span>not_analyzed<span class="pl-pds">"</span></span>,
              <span class="pl-ent">"ignore_above"</span>: <span class="pl-c1">256</span>,
              <span class="pl-ent">"doc_values"</span>: <span class="pl-c1">true</span>
            }
          }
        },
        {
          <span class="pl-ent">"long_fields"</span>: {
            <span class="pl-ent">"match"</span>: <span class="pl-s"><span class="pl-pds">"</span>*<span class="pl-pds">"</span></span>,
            <span class="pl-ent">"match_mapping_type"</span>: <span class="pl-s"><span class="pl-pds">"</span>long<span class="pl-pds">"</span></span>,
            <span class="pl-ent">"mapping"</span>: {
              <span class="pl-ent">"type"</span>: <span class="pl-s"><span class="pl-pds">"</span>long<span class="pl-pds">"</span></span>,
              <span class="pl-ent">"doc_values"</span>: <span class="pl-c1">true</span>
            }
          }
        },
        {
          <span class="pl-ent">"double_fields"</span>: {
            <span class="pl-ent">"match"</span>: <span class="pl-s"><span class="pl-pds">"</span>*<span class="pl-pds">"</span></span>,
            <span class="pl-ent">"match_mapping_type"</span>: <span class="pl-s"><span class="pl-pds">"</span>double<span class="pl-pds">"</span></span>,
            <span class="pl-ent">"mapping"</span>: {
              <span class="pl-ent">"type"</span>: <span class="pl-s"><span class="pl-pds">"</span>double<span class="pl-pds">"</span></span>,
              <span class="pl-ent">"doc_values"</span>: <span class="pl-c1">true</span>
            }
          }
        },
        {
          <span class="pl-ent">"date_fields"</span>: {
            <span class="pl-ent">"match"</span>: <span class="pl-s"><span class="pl-pds">"</span>*<span class="pl-pds">"</span></span>,
            <span class="pl-ent">"match_mapping_type"</span>: <span class="pl-s"><span class="pl-pds">"</span>date<span class="pl-pds">"</span></span>,
            <span class="pl-ent">"mapping"</span>: {
              <span class="pl-ent">"type"</span>: <span class="pl-s"><span class="pl-pds">"</span>date<span class="pl-pds">"</span></span>,
              <span class="pl-ent">"doc_values"</span>: <span class="pl-c1">true</span>
            }
          }
        }
      ]
    }
  }
}</pre></div>
<p dir="auto">Relates to <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="206740011" data-permission-text="Title is private" data-url="https://github.com/elastic/elasticsearch/issues/23101" data-hovercard-type="issue" data-hovercard-url="/elastic/elasticsearch/issues/23101/hovercard" href="https://github.com/elastic/elasticsearch/issues/23101">#23101</a></p>
<p dir="auto">In that issue, we documented <code class="notranslate">eager_global_ordinals</code> and we loosely document the purpose global ordinals. However, do not document when global ordinals actually gets used, which makes it more predictable for people to understand why their memory usage may go up for doc value fields.</p>
<p dir="auto">Examples that may surprise users are implied by the existing documentation, but calling them out would be helpful.</p>
<p dir="auto">Using any <code class="notranslate">keyword</code> fields with <code class="notranslate">doc_values</code> enabled (default) and <code class="notranslate">text</code> fields with <code class="notranslate">fielddata</code> enabled (not default).</p>
<ul dir="auto">
<li>Sorting</li>
<li>Aggregating</li>
<li>Scripting</li>
</ul>
<p dir="auto">Having the caveats of global ordinals documented should lead to a little better understanding, and it may hopefully help us to reduce their usage overall.</p>