lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Hatcher <e...@ehatchersolutions.com>
Subject Re: Using SpanRegexQuery to search year like 200?
Date Sat, 09 Sep 2006 02:15:05 GMT
To use SpanRegexQuery, you need to understand regular expressions.   
The WildcardQuery syntax is _NOT_ the same as SpanRegexQuery syntax.   
WildcardQuery supports a ? for single character match and * for  
multiple characters.  SpanRegexQuery use standard regular expression  
syntax.

"200?" matches 20 and 200, but not 2001 (using java.util.regex, that  
is).

	<http://java.sun.com/j2se/1.4.2/docs/api/java/util/regex/Pattern.html>

"X? matches X, once or not at all"

Use "200.?" perhaps, or more appropriately for matching any year 2000  
- 2009 as "200\d".

	Erik




On Sep 8, 2006, at 8:50 PM, Luke Tan wrote:

> Hi,
>
> Can this be use to search year 2000, 2001, 2002, ... 2009?
>
> SpanFirstQuery snq = new SpanFirstQuery(new SpanRegexQuery(new Term 
> ("year",
> "200?")), 1);
>
>
> I need to use it to search something like
>
> Who is born in 200?
>
> Thanks


---------------------------------------------------------------------
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