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 Van Nguyen <vn...@ur.com> on 2006/07/13 00:09:10 UTC

how to find out if two fields are identical?

Is there a way to compare the values of two fields to see if they are
the same?

 

Let's say we have an index with these fields:

 

ID:                2

childID:         7

parentID:       0

--------------------

ID:                3

childID:         6

parentID:       5

--------------------

ID:                4

childID:         2

parentID:       2

--------------------

 

Based on these three documents, I want the query to return the third
document where childID=parentID.


Re: how to find out if two fields are identical?

Posted by Chris Hostetter <ho...@fucit.org>.
: Based on these three documents, I want the query to return the third
: document where childID=parentID.

the the best of my knowledge there is no easy way to do this using the
existing lucene query types -- but it would be fairly easy to impliment.

Since there are no "scoring" issues involved, i would suggest implimenting
it as a new Filter ... if you can allow yourself the constraint that no
document will have more then one value for either field, you can use the
FieldCache to do this very easily -- just iteratre over the FieldCache
arrays in unison, and record a Bit for each document where the value is
the same.

SOlving the more general case where a document matches if any Term it has
for Field X matches any Term it has for Field Y would certinaly be
trickier.


-Hoss


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org