title: Elasticsearch : Retrieve long text field from a document
body: <p>I have a document indexed in ES. This document have 3 text fields <code>F1</code>, <code>F2</code> and <code>F3</code>.</p>
  
  <p>When I try to search this document using the Java API, I only have the value for fields <code>F1</code> and <code>F2</code>, and field <code>F3</code> appears empty.</p>
  
  <pre><code>QueryBuilder query =  //Some query
  
  SearchResponse response = client.prepareSearch(index)
                  .addDocValueField("F1.keyword")
                  .addDocValueField("F2.keyword")
                  .addDocValueField("F3.keyword")
                  .setQuery(query)
                  .execute()
                  .actionGet();
  
  SearchHit hit = response.getHits().getAt(0);
  
  System.out.println("F1 : "+hit.getField("F1.keyword").getValue());
  System.out.println("F2 : "+hit.getField("F2.keyword").getValue());
  System.out.println("F3 : "+hit.getField("F3.keyword").getValue()); // empty
  </code></pre>
  
  <p>My field <code>F3</code> can be very long. In the document I use for the tests, it does >300 characters, and can be way longer.</p>
  
  <p>My index mapping is : </p>
  
  <pre><code>"mappings": {
        "MyIndex": {
          "properties": {
            "F1": {
              "type": "text",
              "fields": {
                "keyword": {
                  "type": "keyword",
                  "ignore_above": 256
                }
              }
            },
            "F2": {
              "type": "text",
              "fields": {
                "keyword": {
                  "type": "keyword",
                  "ignore_above": 256
                }
              }
            },
            "F3": {
              "type": "text",
              "fields": {
                "keyword": {
                  "type": "keyword",
                  "ignore_above": 256
                }
              }
            }
          }
        }
      }
  </code></pre>
  
  <p>So I updated the <code>ignore_above</code> field in mapping for <code>F3</code> up to 20000 (might be a bad idea ?), but I still have the same behavior.</p>
  
  <p>What is the problem, and what is the correct way to do this ?</p>
  
  <p>Notes : </p>
  
  <ul>
  <li>Using ES 5.6.3</li>
  <li>I don't need to do any analysis / term search on the field <code>F3</code>, only retrieving it's value when a query match <code>F1</code> or <code>F2</code>.</li>
  <li>I will have a small number of document of this kind, so efficiency would not be a big issue</li>
  </ul>
  
  <p>EDIT : </p>
  
  <p>Strange thing is that I have the expected result when I request elasticsearch with my browser with query : </p>
  
  <pre><code>http://localhost:9200/MyIndex/_search?pretty=true?{"query": {"match_all": {}}}
  </code></pre>