I'm just reading the code:

case WILDCARD_ESCAPE:
 // add the next codepoint instead, if it exists
 if (i + length < wildcardText.length()) {
   final int nextChar = wildcardText.codePointAt(i + length);
   length += Character.charCount(nextChar);
   automata.add(BasicAutomata.makeChar(nextChar));
   break;
 } // else fallthru, lenient parsing with a trailing \


So, if the user places a backslash before a non-wild character, the backslash will be discarded. For example:

   abc\\def-x*y

As is, the code will remove that first backslash and include the next character from the pattern string, which happens to be a backslash as well.

If the user merely wrote:

   abc\def-x*y

As is, the code will remove the backslash and merely accept the next character.

So, if the user wants a backslash in their wildcard term, it does need to be escaped. I think. If I am wrong, please explain further.

-- Jack Krupansky

-----Original Message----- From: Robert Muir
Sent: Thursday, September 13, 2012 3:01 PM
To: [email protected]
Subject: Re: svn commit: r1384427 - /lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/WildcardQuery.java

But thats not true.

On Thu, Sep 13, 2012 at 2:52 PM, Jack Krupansky <[email protected]> wrote:
Technically, should also indicate that backslashes need to be escaped to
include them in a wildcard term.

-- Jack Krupansky

-----Original Message----- From: [email protected]
Sent: Thursday, September 13, 2012 1:42 PM
To: [email protected]
Subject: svn commit: r1384427 -
/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/WildcardQuery.java


Author: rmuir
Date: Thu Sep 13 17:42:18 2012
New Revision: 1384427

URL: http://svn.apache.org/viewvc?rev=1384427&view=rev
Log:
add note about escaping terms

Modified:

lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/WildcardQuery.java

Modified:
lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/WildcardQuery.java
URL:
http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/WildcardQuery.java?rev=1384427&r1=1384426&r2=1384427&view=diff
==============================================================================
---
lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/WildcardQuery.java
(original)
+++
lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/WildcardQuery.java
Thu Sep 13 17:42:18 2012
@@ -28,7 +28,10 @@ import java.util.List;

/** Implements the wildcard search query. Supported wildcards are
<code>*</code>, which
 * matches any character sequence (including the empty one), and
<code>?</code>,
- * which matches any single character. Note this query can be slow, as it
+ * which matches any single character. If you want to treat a wildcard as a
literal
+ * character instead, escape it with '\'.
+ * <p>
+ * Note this query can be slow, as it
 * needs to iterate over many terms. In order to prevent extremely slow
WildcardQueries,
 * a Wildcard term should not start with the wildcard <code>*</code>
 *


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]




--
lucidworks.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to