You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Th...@gmx.net on 2005/02/01 11:42:23 UTC

Adding Fields to Document (with same name)

Hi,

what happens when I add two fields with the same name to one Document?

Document doc = new Document();
doc.add(Field.Text("bla", "this is my first text"));
doc.add(Field.Text("bla", "this is my second text"));

Will the second text overwrite the first, because only one field can be held
with the same name in one document?

Will the first and the second text be merged, when I search in the field bla
(e.g. with query "bla:text") ?

I am working on XML indexing and did not get an error when having repeated
XML fields. Now I am wondering...

Karl

-- 
Sparen beginnt mit GMX DSL: http://www.gmx.net/de/go/dsl

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


Re: Adding Fields to Document (with same name)

Posted by Chris Lamprecht <cl...@gmail.com>.
Hi Karl,

>From _Lucene in Action_, section 2.2, when you add the same field with
different values, "Internally, Lucene appends all the words together
and index them in a single Field ..., allowing you to use any of the
given words when searching."

See also http://www.lucenebook.com/search?query=appendable+fields

-chris

On Tue, 1 Feb 2005 11:42:23 +0100 (MET), TheRanger@gmx.net
<Th...@gmx.net> wrote:
> Hi,
> 
> what happens when I add two fields with the same name to one Document?
> 
> Document doc = new Document();
> doc.add(Field.Text("bla", "this is my first text"));
> doc.add(Field.Text("bla", "this is my second text"));
> 
> Will the second text overwrite the first, because only one field can be held
> with the same name in one document?
> 
> Will the first and the second text be merged, when I search in the field bla
> (e.g. with query "bla:text") ?
> 
> I am working on XML indexing and did not get an error when having repeated
> XML fields. Now I am wondering...
> 
> Karl
> 
> --
> Sparen beginnt mit GMX DSL: http://www.gmx.net/de/go/dsl
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: lucene-user-help@jakarta.apache.org
> 
>

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