title: Elastic Search sorting very slow on large datasets
body: <p>The sorting of data in ES was very fast when I had less data, but when the data increased into GBs then the sorting of the fields is very very slow, normal fields &lt; 1 sec, but for the fields with the below mapping the sorting time is &gt; 10 seconds and sometimes more.</p>
  <p>I am unable to figure out why is that? can anyone help me with this?</p>
  <p>Mapping:</p>
  <pre><code>&quot;newFields&quot;: {
      &quot;type&quot;: &quot;nested&quot;,
      &quot;properties&quot;: {
        &quot;group&quot;: { &quot;type&quot;: &quot;keyword&quot; },
        &quot;fieldType&quot;: { &quot;type&quot;: &quot;keyword&quot; },
        &quot;name&quot;: { &quot;type&quot;: &quot;keyword&quot; },
        &quot;stringValue&quot;: {
          &quot;type&quot;: &quot;text&quot;,
          &quot;fields&quot;: {
            &quot;keyword&quot;: {
              &quot;type&quot;: &quot;keyword&quot;,
              &quot;ignore_above&quot;: 256,
              &quot;normalizer&quot;: &quot;sort_normalizer&quot;
            }
          }
        },
        &quot;longValue&quot;: {
          &quot;type&quot;: &quot;long&quot;
        },
        &quot;doubleValue&quot;: {
          &quot;type&quot;: &quot;float&quot;
        },
        &quot;booleanValue&quot;: {
          &quot;type&quot;: &quot;boolean&quot;
        }
      }
    }
  </code></pre>
  <p>Query:</p>
  <pre><code> {
    &quot;index&quot;: &quot;transactions-read&quot;,
    &quot;body&quot;: {
      &quot;query&quot;: {
        &quot;bool&quot;: { &quot;filter&quot;: { &quot;bool&quot;: { &quot;must&quot;: [{ &quot;match_all&quot;: {} }] } } }
      },
      &quot;sort&quot;: [
        {
          &quot;newFields.intValue&quot;: {
            &quot;order&quot;: &quot;desc&quot;,
            &quot;nested&quot;: {
              &quot;path&quot;: &quot;newFields&quot;,
              &quot;filter&quot;: { &quot;match&quot;: { &quot;newFields.name&quot;: &quot;johndoe&quot; } }
            }
          }
        }
      ]
    },
    &quot;from&quot;: 0,
    &quot;size&quot;: 50
  }
  </code></pre>
  <p>So is there any way to make it faster? Or am I missing something here?</p>