lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Yonik Seeley" <yo...@apache.org>
Subject Re: indexing and searching real numbers
Date Fri, 06 Apr 2007 17:20:10 GMT
On 4/5/07, Leon <lmikhailov@netzero.net> wrote:
> I need to index and search real numbers in Lucene. I found NumberUtils class
> in Solr project which permits one to encode doubles into string so that
> alpha numeric ordering would correctly correspond to the ordering on
> numbers. When I use ConstantScoreRangeQuery programmatically everything
> works just fine. However when I convert this query to a string, parse it
> with QueryParser and use the resulting query – no result are found.
>
> ConstantScoreRangeQuery wquery =
>   new ConstantScoreRangeQuery("westbc", null,
> NumberUtils.double2sortableStr(-110.500000), false, true);
> Hits hits = is.search(wquery); //returns expected results
>
> Now if I do
>
> String wqueryString = wquery.toString();
> QueryParser queryParser = new QueryParser("westbc", new KeywordAnalyzer());
> Query query = queryParser.parse(wqueryString);
> Hits hits = is.search(query); // returns nothing

Query.toString() is really for debugging only, and I don't believe
current implementations try to escape characters that might be interpreted
as something else if reparsed.

Simple example...  I think
(new TermQuery(new Term("foo","\"a\""))).toString() would yield
foo:"a"
which if put through the query parser, would be parsed as
foo:a

-Yonik

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


Mime
View raw message