lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jonathan Hager <jha...@gmail.com>
Subject Re: Range Query
Date Tue, 19 Oct 2004 22:00:40 GMT
That is exactly right.  It is searching the ASCII.  To solve it I pad
my price using a method like this:

  /**
   * Pads the Price so that all prices are the same number of characters and
   * can be compared lexigraphically.
   * @param price
   * @return
   */
  public static String formatPriceAsString(Double price) {
    if (price == null) {
      return null;
    }
    return PRICE_FORMATTER.format(price.doubleValue());
  }

where PRICE_FORMATTER contains enough digits for your largest number.

  private static final DecimalFormat PRICE_FORMATTER = new
DecimalFormat("0000000.00");

When searching I also pad the query term.  I looked into hooking into
QueryParser, but since the lower/upper prices for my application are
different inputs, I choose to handle them without hooking into the
QueryParser.

Jonathan


On Tue, 19 Oct 2004 12:35:06 +0530, Karthik N S
<karthik@controlnet.co.in> wrote:
> 
> Hi
> 
> Guys
> 
> Apologies.........
> 
> I  have  a Field Type  "Text"  'ItemPrice' ,  Using it to Store  " Price
> Factor in numeric " such as  10, 25.25 , 50.00....
> 
> If I am suppose to Find the Range factor  between 2   prices
> 
> ex -
>                  Contents:shoes +ItemPrice:[10.00 TO 50.60]
> 
> I get results  other  then the Range that has been  executed   [This may be
> due to query parsing the Ascii values instead of  numeric values ]
> 
> Am  I am missing something in the Querry syntax  or Is this the wrong way to
> construct the Query.
> 
> Please Somebody Advise me.... ASAP.....  :(
> 
> Thx in advance
> 
>       WITH WARM REGARDS
>       HAVE A NICE DAY
>       [ N.S.KARTHIK]
> 
> ---------------------------------------------------------------------
> 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