This is how you do it:

foreach (var value in fieldValues)
{
        var fld = new Field("SomeName", value, Field.Store.NO/YES,
Field.Index.TOKENIZED/UN_TOKENIZED);
        doc.Add(fld);
}

There are a couple of things you need to know:




On Mon, Nov 9, 2009 at 12:52 PM, Sean Carpenter <stcarpen...@gmail.com>wrote:

> That's all there is to it.  Add a field multiple times with the same
> name and all of the values will be searchable.
>
> Sean Carpenter
>
> On Sun, Nov 8, 2009 at 7:26 PM, Michael Garski <mgar...@myspace-inc.com>
> wrote:
> > I've not done it, but I believe you can just add another field with the
> same
> > name. The process of appending the second value for the field happens
> > internally. Check the javadocs for 2.4 under the Document.Add method
> where
> > the field is added to the document to confirm.
> >
> > Michael
> >
> > On Nov 7, 2009, at 3:37 AM, André Maldonado <andre.maldon...@gmail.com>
> > wrote:
> >
> >> Hi Nitin. Understood, but how I do it?
> >>
> >> What method I have to use to add multiple values?
> >>
> >> Thank's
> >>
> >> "Então aproximaram-se os que estavam no barco, e adoraram-no, dizendo:
> És
> >> verdadeiramente o Filho de Deus." (Mateus 14:33)
> >>
> >>
> >> On Sat, Nov 7, 2009 at 03:13, Nitin Shiralkar
> >> <nit...@coreobjects.com>wrote:
> >>
> >>> Yes, you can add multiple values using same field name and all the
> values
> >>> would get indexed. So your searches would work fine. However since you
> >>> are
> >>> storing the field, you need to remember that Lucene will only return
> last
> >>> value indexed under that field. If you intend to retrieve all values,
> >>> then
> >>> you can consider adding a dummy field with all values concatenated
> >>> together.
> >>>
> >>>
> >>> -----Original Message-----
> >>> From: André Maldonado [mailto:andre.maldon...@gmail.com]
> >>> Sent: Saturday, November 07, 2009 12:55 AM
> >>> To: lucene-net-user@incubator.apache.org
> >>> Subject: Multi-valued fields
> >>>
> >>> Hi all.
> >>>
> >>> There's a way to create a multi-valued field in Lucene.net? Something
> >>> like?
> >>>
> >>> Field f = new Field("categories", "", Field.Store.YES,
> >>> Field.Index.ANALYZED);
> >>> f.AddValue("baby")
> >>> f.AddValue("black cat")
> >>> f.AddValue("brown horse")
> >>>
> >>> Thank's
> >>>
> >>> "Então aproximaram-se os que estavam no barco, e adoraram-no, dizendo:
> És
> >>> verdadeiramente o Filho de Deus." (Mateus 14:33)
> >>>
> >
>

Reply via email to