Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Lucene: Java-User

Could one filed include more than one value?

 

 

Lucene java-user RSS feed   Index | Next | Previous | View Threaded


xuwenhao2008 at gmail

Nov 10, 2009, 12:44 AM

Post #1 of 5 (531 views)
Permalink
Could one filed include more than one value?

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.

--
~_~


anshumg at gmail

Nov 10, 2009, 12:55 AM

Post #2 of 5 (504 views)
Permalink
Re: Could one filed include more than one value? [In reply to]

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 [at] gmail> 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.
>
> --
> ~_~
>


xuwenhao2008 at gmail

Nov 10, 2009, 1:20 AM

Post #3 of 5 (501 views)
Permalink
Re: Could one filed include more than one value? [In reply to]

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 [at] gmail> 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 [at] gmail> 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.
> >
> > --
> > ~_~
> >
>



--
~_~


anshumg at gmail

Nov 10, 2009, 1:51 AM

Post #4 of 5 (496 views)
Permalink
Re: Could one filed include more than one value? [In reply to]

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 [at] gmail> 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 [at] gmail> 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 [at] gmail>
> 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.
> > >
> > > --
> > > ~_~
> > >
> >
>
>
>
> --
> ~_~
>


xuwenhao2008 at gmail

Nov 10, 2009, 10:22 AM

Post #5 of 5 (483 views)
Permalink
Re: Could one filed include more than one value? [In reply to]

Got it! Thanks!

On Tue, Nov 10, 2009 at 1:51 AM, Anshum <anshumg [at] gmail> wrote:

> 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 [at] gmail> 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 [at] gmail> 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 [at] gmail>
> > 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.
> > > >
> > > > --
> > > > ~_~
> > > >
> > >
> >
> >
> >
> > --
> > ~_~
> >
>



--
~_~

Lucene java-user RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.