lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erick Erickson <erickerick...@gmail.com>
Subject Re: Fields with multiple values...
Date Thu, 12 Feb 2009 00:39:14 GMT
Well, you could index with your index as part of the value...
doc.Add (new Field ("Field1", "1A", Field.Store.YES,
Field.Index.UN_TOKENIZED));
doc.Add (new Field ("Field1", "2B", Field.Store.YES,
Field.Index.UN_TOKENIZED));

// Add 2 values to Field2.
doc.Add (new Field ("Field2", "1C", Field.Store.YES,
Field.Index.UN_TOKENIZED));
doc.Add (new Field ("Field2", "2D", Field.Store.YES,
Field.Index.UN_TOKENIZED));

then form your queries with all terms specific to one position and OR
together a clause for each possibility, something like this:


   (Field1:1A AND Field2:1C) OR (Field1:2A AND Field2:2C)
which would hit, but


  ( Field1:1A AND Field2:1D) OR (Field1:2A AND Field2:2D)
would fail.


I'm not sure how complex your queries get, so whether this works out for you
is an open question. It's obviously clumsy with a very large number of
tokens per field... How big do you expect your index to get, and how many
index positions do you expect as a max?

Do be aware that UN_TOKENIZED not fold case...

Best
Erick


On Wed, Feb 11, 2009 at 5:55 PM, Dragon Fly <dragon-fly999@hotmail.com>wrote:

>
> Hi,
>
> Let's say I have a single document with 2 fields (namely Field1 and
> Field2).  2 values are added to each field like below.
>
> // Add 2 values to Field1.
> doc.Add (new Field ("Field1", "A", Field.Store.YES,
> Field.Index.UN_TOKENIZED));
> doc.Add (new Field ("Field1", "B", Field.Store.YES,
> Field.Index.UN_TOKENIZED));
>
> // Add 2 values to Field2.
> doc.Add (new Field ("Field2", "C", Field.Store.YES,
> Field.Index.UN_TOKENIZED));
> doc.Add (new Field ("Field2", "D", Field.Store.YES,
> Field.Index.UN_TOKENIZED));
>
> I'd like to get a hit if I do:
>    Field1:A AND Field2:C
> This is fine because that's how Lucene works.  However, I do not want to
> get a hit if I do:
>    Field1:A AND Field2:D
> The reason that I don't want a hit is because A is the first element in
> Field1 and D is the second element in Field2.  I only want a hit when both
> values are at the same array index.  Is there a way to do this? Thank you in
> advance for your help.
>
> _________________________________________________________________
> Windows Liveā„¢: E-mail. Chat. Share. Get more ways to connect.
> http://windowslive.com/explore?ocid=TXT_TAGLM_WL_t2_allup_explore_022009

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