title: Lucene 6.2.1 - IllegalStateException "field-name" was indexed without position data; cannot run SpanTermQuery
body: <p>I am not familiar with lucene . Recently I got a chance to involve in a work where they are moving from old lucene version 2.4.1 to <strong>6.2.1</strong> for their application. </p>
  
  <p>While running with new version 6.2.1, we are facing an exception while searching: </p>
  
  <blockquote>
    <p>Exception during query field "field_name" was indexed without position data; cannot run SpanTermQuery (term=2887629129)**</p>
  </blockquote>
  
  <p>In code, the field is created as follows:</p>
  
  
  
  <pre class="lang-java prettyprint-override"><code>doc.add(new Field("field_1", "field_value", StringField.TYPE_STORED));
  </code></pre>
  
  <p>Finally we tried as given below:</p>
  
  <pre class="lang-java prettyprint-override"><code>FieldType type = new FieldType();
  type.setStored(true);
  type.setIndexOptions(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS);
  doc.add(new Field("field_1", "field_value", StringField.TYPE_STORED));
  </code></pre>
  
  <p>With the above change, the previous error was gone, but we are not receiving any search results, getting empty result.</p>