org.eaglei.lexical.lucene
Class LuceneUtils

java.lang.Object
  extended by org.eaglei.lexical.lucene.LuceneUtils

public class LuceneUtils
extends java.lang.Object

Lucene utility code.

Author:
rfrost

Constructor Summary
LuceneUtils()
           
 
Method Summary
static org.apache.lucene.search.Query escapeIfInvalid(org.apache.lucene.queryParser.QueryParser parser, java.lang.String query)
          Attempts to parse the specified query string using the specified QueryParser.
static org.apache.lucene.search.Query rewriteToFuzzy(org.apache.lucene.search.Query originalQuery)
          Rewrites the specified Query to a form where all contained Terms have the "fuzzy" modifier (Levenstein edit distance) Only rewrites queries that are: BooleanQueries if any clause is more complex than a term or phrase, it is skipped if any clause has the NOT modifier, skip TermQueries
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LuceneUtils

public LuceneUtils()
Method Detail

escapeIfInvalid

public static org.apache.lucene.search.Query escapeIfInvalid(org.apache.lucene.queryParser.QueryParser parser,
                                                             java.lang.String query)
                                                      throws org.apache.lucene.queryParser.ParseException
Attempts to parse the specified query string using the specified QueryParser. If a parsing error is encountered, invalid syntax is escaped and the parse is attempted again.

Parameters:
parser - The QueryParser.
query - The query string
Returns:
Query
Throws:
org.apache.lucene.queryParser.ParseException - Parse exception generated after escaping special syntax.

rewriteToFuzzy

public static org.apache.lucene.search.Query rewriteToFuzzy(org.apache.lucene.search.Query originalQuery)
Rewrites the specified Query to a form where all contained Terms have the "fuzzy" modifier (Levenstein edit distance) Only rewrites queries that are:

Parameters:
originalQuery -
Returns:
Query with child TermQueries rewritten as FuzzyQueries.


Copyright © 2009-2010 Eagle-I. All Rights Reserved.