Mailing List Archive

Trying To Understand Query Syntax Details
I'm trying to understand the details of the query syntax. I found the
syntax ` in QueryParser.jj, but it doesn't make everything clear.

My initial questions:

- It doesn't appear that "?" can be the last character in a search. For
example, to match "fool" and "food", I tried to do "foo?", but got a
parse error. "fo?l" of course matches fool and foal. Is this a bug or an
implementation constraint?

- How does one specify a date range in a query? We need to be able to
search on "docs later than date x", and I know that Lucene supports date
matching, but I don't see how to specify this in a query.

Also, is there a description of the algorithm "~" uses?

Thanks,

E.

--
. . . . . . . . . . . . . . . . . . . . . . . .

W. Eliot Kimber | Lead Brain

1016 La Posada Dr. | Suite 240 | Austin TX 78752
T 512.656.4139 | F 512.419.1860 | eliot@isogen.com

w w w . d a t a c h a n n e l . c o m
RE: Trying To Understand Query Syntax Details [ In reply to ]
Not sure about the rest, but if you've stored your dates in yyyymmdd format,
you can use a RangeQuery like so:

dateField:[20011001-null]

This would return all dates on or after October 1, 2001.

Scott

> -----Original Message-----
> From: W. Eliot Kimber [mailto:eliot@isogen.com]
> Sent: Tuesday, October 16, 2001 11:10 AM
> To: lucene-user
> Subject: Trying To Understand Query Syntax Details
>
>
> I'm trying to understand the details of the query syntax. I found the
> syntax ` in QueryParser.jj, but it doesn't make everything clear.
>
> My initial questions:
>
> - It doesn't appear that "?" can be the last character in a
> search. For
> example, to match "fool" and "food", I tried to do "foo?", but got a
> parse error. "fo?l" of course matches fool and foal. Is this
> a bug or an
> implementation constraint?
>
> - How does one specify a date range in a query? We need to be able to
> search on "docs later than date x", and I know that Lucene
> supports date
> matching, but I don't see how to specify this in a query.
>
> Also, is there a description of the algorithm "~" uses?
>
> Thanks,
>
> E.
>
> --
> . . . . . . . . . . . . . . . . . . . . . . . .
>
> W. Eliot Kimber | Lead Brain
>
> 1016 La Posada Dr. | Suite 240 | Austin TX 78752
> T 512.656.4139 | F 512.419.1860 | eliot@isogen.com
>
> w w w . d a t a c h a n n e l . c o m
>
Re: Trying To Understand Query Syntax Details [ In reply to ]
> Scott Ganyo wrote:
>
> Not sure about the rest, but if you've stored your dates in yyyymmdd
> format, you can use a RangeQuery like so:
>
> dateField:[20011001-null]
>
> This would return all dates on or after October 1, 2001.

Cool--thanks!

E.
--
. . . . . . . . . . . . . . . . . . . . . . . .

W. Eliot Kimber | Lead Brain

1016 La Posada Dr. | Suite 240 | Austin TX 78752
T 512.656.4139 | F 512.419.1860 | eliot@isogen.com

w w w . d a t a c h a n n e l . c o m
Re: Trying To Understand Query Syntax Details [ In reply to ]
--- "W. Eliot Kimber" <eliot@isogen.com> wrote:
> I'm trying to understand the details of the query
> syntax. I found the
> syntax ` in QueryParser.jj, but it doesn't make
> everything clear.
>
> My initial questions:
>
> - It doesn't appear that "?" can be the last
> character in a search. For
> example, to match "fool" and "food", I tried to do
> "foo?", but got a
> parse error. "fo?l" of course matches fool and foal.
> Is this a bug or an
> implementation constraint?

Yes and no. Lucene uses two query classes to handle
wildcards, namely PrefixQuery and WildcardQuery.

To cut the long story short, PrefixQuery, the faster
of the two, is expressly optimized for wildcards
searches like "foo*" and "foa*" but doesn't yet
support single character matching like "foo?".

WildcardQuery, the slower of the two and developed
after PrefixQuery was completed, handles general
wildcard searches like "fo*l" as well as "fo?l".

I'll see what I can do to add single character
matching to PrefixQuery over the weekend.


> - How does one specify a date range in a query? We
> need to be able to
> search on "docs later than date x", and I know that
> Lucene supports date
> matching, but I don't see how to specify this in a
> query.

Try looking at Range Query.

> Also, is there a description of the algorithm "~"
> uses?

"~" is used to toggle fuzzy search on a single word.
Thus the search "foam~" will match with terms like
"foam", "form", "foal", "roam", etc..



__________________________________________________
Do You Yahoo!?
Make a great connection at Yahoo! Personals.
http://personals.yahoo.com