[ 
https://issues.apache.org/jira/browse/LUCENE-5923?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14121249#comment-14121249
 ] 

Sam Halliday commented on LUCENE-5923:
--------------------------------------

another workaround appears to be to synchronize all writes :-/

> 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: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to