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 Derek Baker <de...@idexx.com> on 2004/09/17 19:37:59 UTC
range query problems
Hi,
I'm having a problem with a range query.
I have a field in my documents called "adzer". In at least one of those
documents, the value is: "-000000009999999993" (without the quotes). I
know this because if I create a search string like so: "adzer:
\\-000000009999999993" (again, without the quotes), I get results.
However, if I create a range query that I would expect to find that
value, I get nothing. The range query string is: "adzer:[# TO 0]" (minus
the quotes). As far as I can tell, this query string should find any
value in the adzer fields that starts with a "-". The unicode value for
# comes before the unicode value for - and the unicode value for - comes
before the unicode value for 0. Creating a sample program with the
mentioned Strings and using the compareTo function seems to confirm
this. But Lucene seems to disagree.
Am I missing something here? I've been banging my head on this all day,
and any help would be greatly appreciated.
Derek
---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org
Re: range query problems
Posted by Derek Baker <de...@idexx.com>.
Ah, but if I escape the "0" in the term constructor:
Term term2 = new Term("adzer", "\\0");
It works. And then it works for a dash as well. Seems that to pass a
search string to a queryParser, the "0" has to be escaped doubly:
searchString = "adzer: [# TO \\\\0]";
Just escaping with a double backslash does not work.
I still wonder though, if that is the desired behavior. It does not say
on the page on the Lucene web site, that either "0" or "-" are special
characters that need to be escaped.
Thanks for your time and for pointing me in the right direction.
Derek
Derek Baker wrote:
> Thanks for your reply.
>
> If I do it manually:
>
> Term term1 = new Term("adzer", "#");
> Term term2 = new Term("adzer", "0");
> Query myQuery = new RangeQuery(term1, term2, true);
> hits = searcher.search(myQuery);
>
> I still get nothing. If I make the first term in the new RangeQuery
> call null:
>
> Query myQuery = new RangeQuery(null, term2, true);
>
> I get nothing. If, however I make the second term in the new
> RangeQuery call null:
>
> Query myQuery = new RangeQuery(term1, null, true);
>
> I get the results I expect.
>
> Seems very strange.
>
> Derek
>
> Daniel Naber wrote:
>
>> On Friday 17 September 2004 19:37, Derek Baker wrote:
>>
>>
>>
>>> However, if I create a range query that I would expect to find that
>>> value, I get nothing. The range query string is: "adzer:[# TO 0]"
>>> (minus
>>> the quotes). As far as I can tell, this query string should find any
>>> value in the adzer fields that starts with a "-".
>>>
>>
>>
>> Did you try building that query manually? Maybe even starting from
>> null instead of #.
>>
>> Regards
>> Daniel
>>
>>
>>
>
> ---------------------------------------------------------------------
> 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
Re: range query problems
Posted by Derek Baker <de...@idexx.com>.
Thanks for your reply.
If I do it manually:
Term term1 = new Term("adzer", "#");
Term term2 = new Term("adzer", "0");
Query myQuery = new RangeQuery(term1, term2, true);
hits = searcher.search(myQuery);
I still get nothing. If I make the first term in the new RangeQuery call
null:
Query myQuery = new RangeQuery(null, term2, true);
I get nothing. If, however I make the second term in the new RangeQuery
call null:
Query myQuery = new RangeQuery(term1, null, true);
I get the results I expect.
Seems very strange.
Derek
Daniel Naber wrote:
>On Friday 17 September 2004 19:37, Derek Baker wrote:
>
>
>
>>However, if I create a range query that I would expect to find that
>>value, I get nothing. The range query string is: "adzer:[# TO 0]" (minus
>>the quotes). As far as I can tell, this query string should find any
>>value in the adzer fields that starts with a "-".
>>
>>
>
>Did you try building that query manually? Maybe even starting from null
>instead of #.
>
>Regards
> Daniel
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org
Re: range query problems
Posted by Daniel Naber <da...@t-online.de>.
On Friday 17 September 2004 19:37, Derek Baker wrote:
> However, if I create a range query that I would expect to find that
> value, I get nothing. The range query string is: "adzer:[# TO 0]" (minus
> the quotes). As far as I can tell, this query string should find any
> value in the adzer fields that starts with a "-".
Did you try building that query manually? Maybe even starting from null
instead of #.
Regards
Daniel
--
http://www.danielnaber.de
---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org