lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Anshum <ansh...@gmail.com>
Subject Re: Could one filed include more than one value?
Date Tue, 10 Nov 2009 09:51:47 GMT
I haven't tried multi field query parser. Though about the usage of adding
multiple values while indexing, here's a code snippet that might help.
--snip starts--
IndexWriter iw = new IndexWriter(...);
Document d = new Document();
doc.add(new Field("field", new FileReader(f11));
doc.add(new Field("field", new FileReader(f12));
iw.addDocument(doc);
--snip ends--
--
Anshum Gupta
Naukri Labs!
http://ai-cafe.blogspot.com

The facts expressed here belong to everybody, the opinions to me. The
distinction is yours to draw............


On Tue, Nov 10, 2009 at 2:50 PM, Wenhao Xu <xuwenhao2008@gmail.com> wrote:

> Thanks. Yes, I mean multi valued fileds, but I am still confused how to use
> it.
>
> BTW, I also found another class MultiFieldQueryParser. If I don't  use
> multi
> valued fields, it seems I can use this class to compose a query over
> multiple fields. But is there difference of the result returned with these
> two methods? Or the performance difference?
>
> cheers,
> W.
>
> On Tue, Nov 10, 2009 at 12:55 AM, Anshum <anshumg@gmail.com> wrote:
>
> > If you are talking about multi valued fields, the answer is yes.
> > You may create multiple field objects with the same name and add to the
> > same
> > document.
> > It would lead to adding the values to the same field name for the
> document.
> >
> > --
> > Anshum Gupta
> > Naukri Labs!
> > http://ai-cafe.blogspot.com
> >
> > The facts expressed here belong to everybody, the opinions to me. The
> > distinction is yours to draw............
> >
> >
> > On Tue, Nov 10, 2009 at 2:14 PM, Wenhao Xu <xuwenhao2008@gmail.com>
> wrote:
> >
> > > Hi, guys,
> > >     I have such a problem:
> > >     I have lots of files. In these files, two of them are related to
> each
> > > other and should be deemed as a whole (There is a map file to map them
> > > together). So they are somewhat like a set of pairs of files: <f11,
> f12>,
> > > <f21, f22> , <f31, f32> ... . For a keyword search, the result
should
> > also
> > > be like <fi1, fi2>,....  Their score should be computed together.
> > >
> > >    As far as I know, I could use "doc.add(new Field("field1", new
> > > FileReader(f11)));", and "doc.add(new Field("field2", new
> > > FileReader(f12)))"
> > > for each file respectively.  But in this way, when searching, these two
> > > fields (field1 and field2) can not be searched together in a single
> > search.
> > > As I said, these two files should be deemed as a whole and returned
> > > together. So I am wondering, could I map one filed to more than one
> > value,
> > >    somewhat like doc.add(new Field("field", new FileReader(f11), new
> > > FileReader(f12));
> > >
> > >   Is there some way to do this? Or could you give me some suggestions
> how
> > > to solve this problem?
> > >
> > > Thanks,
> > > W.
> > >
> > > --
> > > ~_~
> > >
> >
>
>
>
> --
> ~_~
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message