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 Rob Outar <ro...@ideorlando.org> on 2003/03/20 14:18:17 UTC

Quick Question On Adding Fields

What happens if I add the same name/value pair to a Lucene Document?  Does
it override it?  Does it append it so you have duplicates?

Let me know,


Rob


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


RE: Quick Question On Adding Fields

Posted by Rob Outar <ro...@ideorlando.org>.
I ran a little test where I did:

doc.add(new Field("name","value"));
doc.add(new Field("name","value"));

Then got a list of the field for that doc and sure enough it is in there
twice.  So it appends whatever value to the field, even if the value already
exists.


Thanks,

Rob


-----Original Message-----
From: David Spencer [mailto:David.Spencer@micromuse.com]
Sent: Thursday, March 20, 2003 8:53 AM
To: Lucene Users List
Subject: Re: Quick Question On Adding Fields


Rob Outar wrote:

>What happens if I add the same name/value pair to a Lucene Document?  Does
>it override it?  Does it append it so you have duplicates?
>
I believe it 'appends' in the sense that if you add 2 fields with the same
name then the Document has the union of the content of both fields
added, and then you can search on anything in either or both of the field
values you added.

One use case is if you're indexing html and you want a field for the
title, a field
for the body, and a easy way for users to refer to both the field and
the body
in a query.

So when you add a Field for the title named "title",
you also add one with a name like "contents", and then
you add a field for the body named "body", and then you
pass the same data and add another field named "contents".
Then, voilla, a search on contents:foo returns matches against
the title and the body.

>
>Let me know,
>
>
>Rob
>
>
>---------------------------------------------------------------------
>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


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


Re: Quick Question On Adding Fields

Posted by David Spencer <Da...@micromuse.com>.
Rob Outar wrote:

>What happens if I add the same name/value pair to a Lucene Document?  Does
>it override it?  Does it append it so you have duplicates?
>
I believe it 'appends' in the sense that if you add 2 fields with the same
name then the Document has the union of the content of both fields
added, and then you can search on anything in either or both of the field
values you added.

One use case is if you're indexing html and you want a field for the 
title, a field
for the body, and a easy way for users to refer to both the field and 
the body
in a query.

So when you add a Field for the title named "title",
you also add one with a name like "contents", and then
you add a field for the body named "body", and then you
pass the same data and add another field named "contents".
Then, voilla, a search on contents:foo returns matches against
the title and the body.

>
>Let me know,
>
>
>Rob
>
>
>---------------------------------------------------------------------
>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