From 1f5a8b17beb1e237efac615c47e1ff4c31d472fd Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Tue, 29 May 2012 15:33:21 +0000 Subject: [PATCH] LUCENE-3982: add regex documentation to CHANGES.txt/qp syntax git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1343779 13f79535-47bb-0310-9956-ffa450edef68 --- lucene/CHANGES.txt | 5 ++++- .../apache/lucene/queryparser/classic/package.html | 11 ++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt index 7af240224ef..71b317525ea 100644 --- a/lucene/CHANGES.txt +++ b/lucene/CHANGES.txt @@ -522,7 +522,10 @@ API Changes New features * LUCENE-2604: Added RegexpQuery support to QueryParser. Regular expressions - are directly supported by the standard queryparser. + are directly supported by the standard queryparser via + fieldName:/expression/ OR /expression against default field/ + Users who wish to search for literal "/" characters are advised to + backslash-escape or quote those characters as needed. (Simon Willnauer, Robert Muir) * LUCENE-1606, LUCENE-2089: Adds AutomatonQuery, a MultiTermQuery that diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/package.html b/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/package.html index de3a4206a80..607e7505603 100644 --- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/package.html +++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/package.html @@ -51,6 +51,9 @@ enabling substantial customization to how a query is created. Wildcard Searches
  • +Regular expression Searches +
  • +
  • Fuzzy Searches
  • @@ -189,6 +192,12 @@ enabling substantial customization to how a query is created.

    You can also use the wildcard searches in the middle of a term.

    te*t

    Note: You cannot use a * or ? symbol as the first character of a search.

    + +

    Regular Expression Searches

    +

    Lucene supports regular expression searches matching a pattern between forward slashes "/". The syntax may change across releases, but the current supported +syntax is documented in the {@link org.apache.lucene.util.automaton.RegExp RegExp} class. For example to find documents containing "moat" or "boat": +

    +
    /[mb]oat/

    Fuzzy Searches

    Lucene supports fuzzy searches based on Damerau-Levenshtein Distance. To do a fuzzy search use the tilde, "~", symbol at the end of a Single word Term. For example to search for a term similar in spelling to "roam" use the fuzzy search:

    @@ -294,7 +303,7 @@ enabling substantial customization to how a query is created.

    Escaping Special Characters

    Lucene supports escaping special characters that are part of the query syntax. The current list special characters are

    -

    + - && || ! ( ) { } [ ] ^ " ~ * ? : \

    +

    + - && || ! ( ) { } [ ] ^ " ~ * ? : \ /

    To escape these character use the \ before the character. For example to search for (1+1):2 use the query:

    \(1\+1\)\:2