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 Hans-Gunther Birken <hg...@t-online.de> on 2010/07/09 14:43:18 UTC
Searching docs with multi-value fields
I'm examining the following search problem. Consider a document with two
multi-value fields.
Document doc = new Document();
doc.add(new Field("f1", "a1", Field.Store.YES, Field.Index.ANALYZED));
doc.add(new Field("f1", "a2", Field.Store.YES, Field.Index.ANALYZED));
doc.add(new Field("f1", "a3", Field.Store.YES, Field.Index.ANALYZED));
doc.add(new Field("f2", "b1", Field.Store.YES, Field.Index.ANALYZED));
doc.add(new Field("f2", "b2", Field.Store.YES, Field.Index.ANALYZED));
doc.add(new Field("f2", "b3", Field.Store.YES, Field.Index.ANALYZED));
The following search expression is applied:
f1:ax AND f2:by
where x, y is 1,2, or 3.
Thus the search condition f1:a2 AND f2:b2 should return the above document
whereas the condition f1:a1 AND f2:b2 should return no result. Thus the
search should return the document if and only if the conditions of each
field are satisfied at the same "index" level.
Does anyone have an idea how to solve this problem using Lucene/Java?
Thanks
HGB
RE: Searching docs with multi-value fields
Posted by Eduardo Pierdant <ed...@occ.com.mx>.
If I understood correctly, you should be done with MultiFieldQueryParser
Eduardo
-----Original Message-----
From: Mark Harwood [mailto:markharw00d@yahoo.co.uk]
Sent: viernes, 09 de julio de 2010 09:30 a.m.
To: java-user@lucene.apache.org
Subject: Re: Searching docs with multi-value fields
Check out lucene 2454 and accompanying slide show if your reason for doing
this is modelling repeating elements.
----------------------------------------
On 9 Jul 2010, at 13:43, "Hans-Gunther Birken" <hg...@t-online.de> wrote:
> I'm examining the following search problem. Consider a document with
> two multi-value fields.
>
>
>
> Document doc = new Document();
>
>
>
> doc.add(new Field("f1", "a1", Field.Store.YES, Field.Index.ANALYZED));
> doc.add(new Field("f1", "a2", Field.Store.YES, Field.Index.ANALYZED));
> doc.add(new Field("f1", "a3", Field.Store.YES, Field.Index.ANALYZED));
>
>
>
> doc.add(new Field("f2", "b1", Field.Store.YES, Field.Index.ANALYZED));
> doc.add(new Field("f2", "b2", Field.Store.YES, Field.Index.ANALYZED));
> doc.add(new Field("f2", "b3", Field.Store.YES, Field.Index.ANALYZED));
>
>
>
> The following search expression is applied:
>
> f1:ax AND f2:by
>
> where x, y is 1,2, or 3.
>
>
>
> Thus the search condition f1:a2 AND f2:b2 should return the above
> document whereas the condition f1:a1 AND f2:b2 should return no
> result. Thus the search should return the document if and only if
> the conditions of each field are satisfied at the same "index" level.
>
>
>
> Does anyone have an idea how to solve this problem using Lucene/Java?
>
>
>
> Thanks
>
> HGB
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: Searching docs with multi-value fields
Posted by Mark Harwood <ma...@yahoo.co.uk>.
Check out lucene 2454 and accompanying slide show if your reason for doing this is modelling repeating elements.
----------------------------------------
On 9 Jul 2010, at 13:43, "Hans-Gunther Birken" <hg...@t-online.de> wrote:
> I'm examining the following search problem. Consider a document with two
> multi-value fields.
>
>
>
> Document doc = new Document();
>
>
>
> doc.add(new Field("f1", "a1", Field.Store.YES, Field.Index.ANALYZED));
> doc.add(new Field("f1", "a2", Field.Store.YES, Field.Index.ANALYZED));
> doc.add(new Field("f1", "a3", Field.Store.YES, Field.Index.ANALYZED));
>
>
>
> doc.add(new Field("f2", "b1", Field.Store.YES, Field.Index.ANALYZED));
> doc.add(new Field("f2", "b2", Field.Store.YES, Field.Index.ANALYZED));
> doc.add(new Field("f2", "b3", Field.Store.YES, Field.Index.ANALYZED));
>
>
>
> The following search expression is applied:
>
> f1:ax AND f2:by
>
> where x, y is 1,2, or 3.
>
>
>
> Thus the search condition f1:a2 AND f2:b2 should return the above document
> whereas the condition f1:a1 AND f2:b2 should return no result. Thus the
> search should return the document if and only if the conditions of each
> field are satisfied at the same "index" level.
>
>
>
> Does anyone have an idea how to solve this problem using Lucene/Java?
>
>
>
> Thanks
>
> HGB
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org