You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Sam Halliday (JIRA)" <ji...@apache.org> on 2014/09/04 13:19:51 UTC

[jira] [Created] (LUCENE-5923) cannot re-use Field in 4.7.2

Sam Halliday created LUCENE-5923:
------------------------------------

             Summary: cannot re-use Field in 4.7.2
                 Key: LUCENE-5923
                 URL: https://issues.apache.org/jira/browse/LUCENE-5923
             Project: Lucene - Core
          Issue Type: Bug
            Reporter: Sam Halliday


I get an exception "first position increment must be > 0 (got 0) for field ..." when I try to re-use a Field as an entry in a Document. Snippet below.

This works ok on lucene 4.9, but I have to go back to 4.7 for Java 6 compatibility.

Workaround is to not re-use the same object in each Document.

(this is Scala)

    private val TypeField = new StringField("TYPE", clazz.getSimpleName, Store.YES)

    final def toDocument(t: T): Document = {
      val doc = new Document
      // Lucene 4.7.2 bug: re-using the common object gives
      // "first position increment must be > 0 (got 0) for field 'TYPE'"
      //doc.add(TypeField)
      doc.add(new StringField("TYPE", clazz.getSimpleName, Store.YES))
      doc.add(new StringField("ID", id(t), Store.NO))
      doc
    }




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org