Elasticsearch first query is slow, rest of them are fast
<p>I'm using this kind of mapping (well, it's a shortener version in order to make the question easier) on a children-parent relationship where <code>item</code> is the parent and <code>user_items</code> is the children.</p>

<pre><code>curl -XPUT 'localhost:9200/myindex?pretty=true' -d '{
  "mappings": {
    "items": {
       "dynamic": "strict",
       "properties" : {
            "title" : { "type": "string" },
            "body" : { "type": "string" },
}},
    "user_items": {
      "dynamic": "strict",
      "_parent": {"type": "items" },
      "properties" : {
            "user_id" : { "type": "integer" },
            "source_id" : { "type": "integer" },
}}}}'
</code></pre>

<p>And the type of query I usually make:</p>

<pre><code>curl -XGET 'localhost:9200/myindex/items/_search?pretty=true' -d '{
    "query": {
      "bool": {
         "must": [
            {
               "query_string": {
                  "fields": ["title", "body"],
                  "query": "mercado"
               }
            },
            {
               "has_child": {
                  "type": "user_items",
                  "query": {
                     "term": {
                        "user_id": 655
    }}}}]}}}'
</code></pre>

<p>On this query it has to search on the fields <code>title</code> and <code>body</code> the string <code>mercado</code> on a given <code>user_id</code>, in this case <code>655</code>.</p>

<p>I read that the reason of being so slow the first query is that it gets cacheed and then the rest queries are fast because it works with the cached content.</p>

<p>I read I can make the first query faster using <strong><a href="https://www.elastic.co/guide/en/elasticsearch/guide/current/preload-fielddata.html" rel="nofollow">eager</a></strong> to preload my data (using <code>"loading" : "eager"</code>, right?) but I dont know what do I've to preload. Do I've to use the <code>earger</code> on <code>title</code> and <code>body</code> as follows?</p>

<pre><code>{
  "mappings": {
    "items": {
       "dynamic": "strict",
       "properties" : {
            "title" : { "type": "string" ,
                        "fielddata": {
                            "loading" : "eager"}},
            "body" : { "type": "string",
                        "fielddata": {
                            "loading" : "eager"}},
}},
    "user_items": {
      "dynamic": "strict",
      "_parent": {"type": "items" },
      "properties" : {
            "user_id" : { "type": "integer" },
            "source_id" : { "type": "integer" },
}}}}'
</code></pre>

<p>Any other recommendation fot boosting/cacheeing the first query is welcome. Thanks in advance</p>

<p>PS: I'm using ES 2.3.2 under a Linux machine and I've a total of 25.396.369 documents.</p>