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 Sven Teichmann <s....@s4ip.de> on 2014/03/25 14:56:41 UTC
Lucene Wildcard for zero or one character
Hello,
does Lucene provide a zero or one character wildcard (like ? in Perl RegEx)?
Example of what I mean:
"house%" finds "house" and "houses"
As far as I know in Lucene the ? wildcard is for exactly one character,
but I need a zero or one character wildcard.
Best regards,
--
Sven Teichmann
______________________________________________________
Software for Intellectual Property GmbH
Gewerbering 14a
83607 Holzkirchen (Germany)
Phone: +49 (0)8024 46699-00
Fax: +49 (0)8024 46699-02
E-Mail: s.teichmann@s4ip.de
Local Court of Munich HRB 125803, UstId DE201282006
General Manager: Alexander Wagner
______________________________________________________
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: Lucene Wildcard for zero or one character
Posted by Jack Krupansky <ja...@basetechnology.com>.
/houses?/
-- Jack Krupansky
-----Original Message-----
From: Uwe Schindler
Sent: Tuesday, March 25, 2014 11:34 AM
To: java-user@lucene.apache.org
Subject: RE: Lucene Wildcard for zero or one character
The default WildcardQuery only supports:
'*' (star) is the wildcard in WildcardQuery for zero or more chars.
'?' is exactly one char
Zero or exatly one char can only be done with a RegexpQuery:
https://lucene.apache.org/core/4_7_0/core/org/apache/lucene/search/RegexpQuery.html
Here is the syntax:
https://lucene.apache.org/core/4_7_0/core/org/apache/lucene/util/automaton/RegExp.html
Query parser supports regex queries since 4.0 with "/" as delimiter:
http://lucene.apache.org/core/4_7_0/queryparser/org/apache/lucene/queryparser/classic/package-summary.html#package_description
Uwe
-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: uwe@thetaphi.de
> -----Original Message-----
> From: Sven Teichmann [mailto:s.teichmann@s4ip.de]
> Sent: Tuesday, March 25, 2014 2:57 PM
> To: java-user@lucene.apache.org
> Subject: Lucene Wildcard for zero or one character
>
> Hello,
>
> does Lucene provide a zero or one character wildcard (like ? in Perl
> RegEx)?
>
> Example of what I mean:
> "house%" finds "house" and "houses"
>
> As far as I know in Lucene the ? wildcard is for exactly one character,
> but I
> need a zero or one character wildcard.
>
> Best regards,
>
> --
> Sven Teichmann
> ______________________________________________________
>
> Software for Intellectual Property GmbH
> Gewerbering 14a
> 83607 Holzkirchen (Germany)
> Phone: +49 (0)8024 46699-00
> Fax: +49 (0)8024 46699-02
> E-Mail: s.teichmann@s4ip.de
>
> Local Court of Munich HRB 125803, UstId DE201282006 General Manager:
> Alexander Wagner
> ______________________________________________________
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
RE: Lucene Wildcard for zero or one character
Posted by Uwe Schindler <uw...@thetaphi.de>.
The default WildcardQuery only supports:
'*' (star) is the wildcard in WildcardQuery for zero or more chars.
'?' is exactly one char
Zero or exatly one char can only be done with a RegexpQuery: https://lucene.apache.org/core/4_7_0/core/org/apache/lucene/search/RegexpQuery.html
Here is the syntax: https://lucene.apache.org/core/4_7_0/core/org/apache/lucene/util/automaton/RegExp.html
Query parser supports regex queries since 4.0 with "/" as delimiter: http://lucene.apache.org/core/4_7_0/queryparser/org/apache/lucene/queryparser/classic/package-summary.html#package_description
Uwe
-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: uwe@thetaphi.de
> -----Original Message-----
> From: Sven Teichmann [mailto:s.teichmann@s4ip.de]
> Sent: Tuesday, March 25, 2014 2:57 PM
> To: java-user@lucene.apache.org
> Subject: Lucene Wildcard for zero or one character
>
> Hello,
>
> does Lucene provide a zero or one character wildcard (like ? in Perl RegEx)?
>
> Example of what I mean:
> "house%" finds "house" and "houses"
>
> As far as I know in Lucene the ? wildcard is for exactly one character, but I
> need a zero or one character wildcard.
>
> Best regards,
>
> --
> Sven Teichmann
> ______________________________________________________
>
> Software for Intellectual Property GmbH
> Gewerbering 14a
> 83607 Holzkirchen (Germany)
> Phone: +49 (0)8024 46699-00
> Fax: +49 (0)8024 46699-02
> E-Mail: s.teichmann@s4ip.de
>
> Local Court of Munich HRB 125803, UstId DE201282006 General Manager:
> Alexander Wagner
> ______________________________________________________
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org