lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chuck Williams" <ch...@manawiz.com>
Subject RE: Filtering Results?
Date Thu, 14 Oct 2004 16:55:07 GMT
Sam,

You can pick any encoding such that lexicographic order (alphabetic
order) is consistent with the numeric order you want.  E.g., if a single
field can contain positive or negative integers or floats, then the
following should work:
1.  First character of every value represents the sign.  You can't use +
and - since + is alphabetically before - (which would make positives
smaller than negatives), so pick a different character to represent +
like maybe =.
2.  Characters 2 through n are a fixed length string that presents the
integer part of the number, padded with leading zeroes.
3.  You don't need padding on the right since longer strings
alphabetically follow shorter strings.  Just included the decimal point
if the number is float, and trail out whatever remaining digits
naturally print.
4.  One other subtlety occurs if you need to ensure that 2 and 2.0 are
equal.  You need to transform one to the other (if you can have both
integers and floats in a single field -- otherwise this is not an
issue).  You will lose information about the original type.

I haven't tested the above, but think it should work.

Chuck

> -----Original Message-----
> From: sam s [mailto:tamputampu@hotmail.com]
> Sent: Thursday, October 14, 2004 6:40 AM
> To: lucene-user@jakarta.apache.org
> Subject: RE: Filtering Results?
> 
> Thanks Chuck.
> 
> What is the workaround for filtering (preferably using RangeQuery)
> following?
> 1. Float values. Do I have to pad those with zeros on both sides?
> 2. Negative numbers (integer as well as floats)
> 
> Thanks
> 
> >From: "Chuck Williams" <chuck@manawiz.com>
> >Reply-To: "Lucene Users List" <lucene-user@jakarta.apache.org>
> >To: "Lucene Users List" <lucene-user@jakarta.apache.org>
> >Subject: RE: Filtering Results?
> >Date: Wed, 13 Oct 2004 21:49:30 -0700
> >
> >RangeQuery is a good approach.  Put fields on your documents like
age.
> >The only tricky thing is that the comparisons are all done
> >lexicographically rather that numerically.  Lucene has a built-in
> >routine to convert dates into a monotonic lexicographic sequence
> >(DateField.timeToString).  For positive integer data types like age,
it
> >is sufficient to store them as fixed line String's, e.g.:
> >   5 --> "005"
> >  18 --> "018"
> >100 --> "100"
> >
> >Then just access range queries.  E.g.:
> >1.  age:[018 TO]
> >2.  age:[TO 018]
> >3.  age:[005 TO 018]
> >
> >Those are <= queries.  Use {} instead of [] for < queries.
> >
> >Good luck,
> >
> >Chuck
> >
> > > -----Original Message-----
> > > From: sam s [mailto:tamputampu@hotmail.com]
> > > Sent: Wednesday, October 13, 2004 12:55 PM
> > > To: lucene-user@jakarta.apache.org
> > > Subject: Filtering Results?
> > >
> > > Hi,
> > > I want to do filtering on matched results of a query.
> > > For example
> > > 1. age > 18
> > > 2. age < 18
> > > 3. age > 5 and age < 18
> > > 4. birthdate = [some date]
> > > What can be the best approach?
> > > How can it be done with range query?
> > > Can it be done without range query?
> > >
> > > Also.
> > > Where can I find information meaning of following classes and how
to
> >use
> > > them?
> > > FilteredQuery
> > > QueryFilter (I didnt understand much looking at test case of this)
> > > CachingWrapperFilter
> > > etc..
> > >
> > > Thanks in advance
> > >
> > > _________________________________________________________________
> > > Don't just search. Find. Check out the new MSN Search!
> > > http://search.msn.com/
> > >
> > >
> > >
---------------------------------------------------------------------
> > > To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail:
lucene-user-help@jakarta.apache.org
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
> >For additional commands, e-mail: lucene-user-help@jakarta.apache.org
> >
> 
> _________________________________________________________________
> Don't just search. Find. Check out the new MSN Search!
> http://search.msn.com/
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: lucene-user-help@jakarta.apache.org


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


Mime
View raw message