lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Hatcher <>
Subject Re: Custom sort/basic question
Date Tue, 22 Nov 2005 18:00:21 GMT

On 22 Nov 2005, at 11:29, Gus Kormeier wrote:
> Hey John,
> 	My understanding is that if you add a field with the same name as a
> previous field added, you will be overwriting the value stored in the
> document.
> So if you add:
> doc.add(Field.Text("sequence", "1"));
> doc.add(Field.Text("sequence", "2"));
> doc.add(Field.Text("sequence", "3"));
> Afterwards, the field sequence would hold a value of 3.

That is incorrect.  Adding fields with the same name _appends_ them,  
it does not overwrite them.  In your example, it would be (ignoring  
the Analyzer part of the equation for the moment, as if you had just  
added one sequence field like this:

	doc.add(Field.Text("sequence", "1 2 3"));

Do note that I just made an enhancement to Lucene that allows custom  
analyzers to affect the gaps between multiple fields of the same  
name.  In your example, a PhraseQuery of "1 2" would match the  
document, but in one of my projects that is undesirable.

To answer the previous question, yes, the fields are added in order,  
so you could rely on the indexes to line up.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message