Mailing List Archive

Do range queries work?
Is range searching working in RC2?

I have the following documents in my index (using StandardAnalyzer):

id:doc1
age:30
FirstName:John

id:doc2
age:40
FirstName:Wendy

The following queries do not return the expected results (using QueryParser
with StandardAnalyzer):

"age:[20-35]" finds 2 documents, should find 1
"age:[35-50]" finds 2 documents, should find 1

"FirstName:[a-k]" finds 0 documents, should find 1
"FirstName:[u-z]" finds 0 documents, should find 1
"FirstName:[adam-larry]" finds 0 documents, should find 1

Thanks.

--
To unsubscribe, e-mail: <mailto:lucene-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-user-help@jakarta.apache.org>
RE: Do range queries work? [ In reply to ]
Can folks please try to include complete, self-contained test cases when
submitting bugs? It's not that hard, and makes it much easier to figure out
what is going on.

For example, I have attached a complete, self-contained test case for the
bug reported below. It only took 50 lines. Interestingly, the results it
returns are quite different than those reported. Not that it works as
desired! My results are:

age:[20-35-null]: 2 hits ( doc1 doc2 )
age:[35-50-null]: 1 hits ( doc2 )
FirstName:[k-null]: 1 hits ( doc2 )
FirstName:[u-z]: 1 hits ( doc2 )
FirstName:[adam-larry]: 1 hits ( doc1 )

(Note that I'm re-printing the parsed query to show how it was parsed.) It
looks like StandardAnalyzer parses 20-35 as a single term, causing problems
with the age queries. The FirstName queries work as desired for me. I
suspect that in your case the FirstName field may not have been added as a
Field.Text, but as a case-sensitive Field.Keyword.

In any case, it is much easier to figure out what is going on if a complete
test case is provided in the first place.

So far as I can tell, RangeQuery is doing what it is supposed to.

Doug

> -----Original Message-----
> From: Paul Friedman [mailto:pfriedman@macromedia.com]
> Sent: Thursday, November 01, 2001 6:46 AM
> To: 'Lucene Users List'
> Subject: Do range queries work?
>
>
> Is range searching working in RC2?
>
> I have the following documents in my index (using StandardAnalyzer):
>
> id:doc1
> age:30
> FirstName:John
>
> id:doc2
> age:40
> FirstName:Wendy
>
> The following queries do not return the expected results
> (using QueryParser
> with StandardAnalyzer):
>
> "age:[20-35]" finds 2 documents, should find 1
> "age:[35-50]" finds 2 documents, should find 1
>
> "FirstName:[a-k]" finds 0 documents, should find 1
> "FirstName:[u-z]" finds 0 documents, should find 1
> "FirstName:[adam-larry]" finds 0 documents, should find 1
>
> Thanks.
>
> --
> To unsubscribe, e-mail:
> <mailto:lucene-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
<mailto:lucene-user-help@jakarta.apache.org>
RE: Do range queries work? [ In reply to ]
First, let me apologize for not including a self-contained test in my
original submission. I will do so for any future issues.

In regards to the test case that you included in your response...

It looks like there is a bug (besides the StandardAnalyzer parsing 20-35 as
a single term). The query in your example:

search(searcher, analyzer, "FirstName:[a-k]");

is not finding the correct document. It is finding doc2, it should find
doc1. QueryParser is parsing the query into "FirstName:[k-null]" when it
should be "FirstName:[a-k]". Is "a" being caught as a stop word?

Thanks for the quick response.
Paul

-----Original Message-----
From: Doug Cutting [mailto:DCutting@grandcentral.com]
Sent: Thursday, November 01, 2001 11:36 AM
To: 'Lucene Users List'
Subject: RE: Do range queries work?


Can folks please try to include complete, self-contained test cases when
submitting bugs? It's not that hard, and makes it much easier to figure out
what is going on.

For example, I have attached a complete, self-contained test case for the
bug reported below. It only took 50 lines. Interestingly, the results it
returns are quite different than those reported. Not that it works as
desired! My results are:

age:[20-35-null]: 2 hits ( doc1 doc2 )
age:[35-50-null]: 1 hits ( doc2 )
FirstName:[k-null]: 1 hits ( doc2 )
FirstName:[u-z]: 1 hits ( doc2 )
FirstName:[adam-larry]: 1 hits ( doc1 )

(Note that I'm re-printing the parsed query to show how it was parsed.) It
looks like StandardAnalyzer parses 20-35 as a single term, causing problems
with the age queries. The FirstName queries work as desired for me. I
suspect that in your case the FirstName field may not have been added as a
Field.Text, but as a case-sensitive Field.Keyword.

In any case, it is much easier to figure out what is going on if a complete
test case is provided in the first place.

So far as I can tell, RangeQuery is doing what it is supposed to.

Doug

> -----Original Message-----
> From: Paul Friedman [mailto:pfriedman@macromedia.com]
> Sent: Thursday, November 01, 2001 6:46 AM
> To: 'Lucene Users List'
> Subject: Do range queries work?
>
>
> Is range searching working in RC2?
>
> I have the following documents in my index (using StandardAnalyzer):
>
> id:doc1
> age:30
> FirstName:John
>
> id:doc2
> age:40
> FirstName:Wendy
>
> The following queries do not return the expected results
> (using QueryParser
> with StandardAnalyzer):
>
> "age:[20-35]" finds 2 documents, should find 1
> "age:[35-50]" finds 2 documents, should find 1
>
> "FirstName:[a-k]" finds 0 documents, should find 1
> "FirstName:[u-z]" finds 0 documents, should find 1
> "FirstName:[adam-larry]" finds 0 documents, should find 1
>
> Thanks.
>
> --
> To unsubscribe, e-mail:
> <mailto:lucene-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
<mailto:lucene-user-help@jakarta.apache.org>

--
To unsubscribe, e-mail: <mailto:lucene-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-user-help@jakarta.apache.org>
RE: Do range queries work? [ In reply to ]
> From: Paul Friedman [mailto:pfriedman@macromedia.com]
>
> It looks like there is a bug (besides the StandardAnalyzer
> parsing 20-35 as a single term). The query in your example:
>
> search(searcher, analyzer, "FirstName:[a-k]");
>
> is not finding the correct document. It is finding doc2, it
> should find doc1. QueryParser is parsing the query into
> "FirstName:[k-null]" when it
> should be "FirstName:[a-k]". Is "a" being caught as a stop word?

It looks like it.

I think the real bug here is that QueryParser should not analyze the terms
in a range query. I have modified QueryParser.jj to not do this and all of
your examples work much better. The only downside that I can see is that
range queries, like prefix queries, become case sensitive. That seems like
a good tradeoff to me. Does anyone object to this?

Doug
RE: Do range queries work? [ In reply to ]
>Can folks please try to include complete, self-contained test cases when
>submitting bugs? It's not that hard, and makes it much easier to figure out
>what is going on.

In the WebMacro project, we've actually gone further than that -- no bug
report is taken seriously without a JUnit test case that demonstrates
it. This has been very successful for us, and along the way, we've built a
nice little suite of tests. JUnit test cases are really easy to write, but
so far, the only one in the Lucene repo is the one for the query parser.

I'd like to see the existing test programs converted into JUnit test cases
-- I'm willing to do this if someone will tell me how they work and what
they're supposed to output and how to invoke them.



--
Brian Goetz
Quiotix Corporation
brian@quiotix.com Tel: 650-843-1300 Fax: 650-324-8032

http://www.quiotix.com


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