title: ElasticSearch get offsets of highlighted snippets
body: <p>Is it possible to get character positions of each highlighted fragment? I need to match the highlighted text back to the source document and having character positions would make it possible.</p>
  
  <p>For example: </p>
  
  <pre><code>curl "localhost:9200/twitter/tweet/_search?pretty=true" -d '{
      "query": {
          "query_string": {
              "query": "foo"
          }
      },
      "highlight": {
          "fields": {
              "message": {"number_of_fragments": 20}
          }
      }    
  }'
  </code></pre>
  
  <p>returns this highglight:</p>
  
  <pre><code>"highlight" : {
      "message" : [ "some &lt;em&gt;foo&lt;/em&gt; text" ]
   }
  </code></pre>
  
  <p>If the field message in the matched document were:</p>
  
  <pre><code>"Here is some foo text"
  </code></pre>
  
  <p>is there a way to know that the snippet begins at char 8 and ends at char 21 of the matched field?</p>
  
  <p>Knowing the start/end offset of the matched <strong>token</strong> would be good for me as well - perhaps there is a way to access that information using script_fields? (This <a href="https://stackoverflow.com/questions/13178550/elasticsearch-return-the-tokens-of-a-field">question</a> shows how to obtain the tokens, but not the offsets). </p>
  
  <p>The field "message" has:</p>
  
  <pre><code>"term_vector" : "with_positions_offsets",
  "index_options" : "positions" 
  </code></pre>