org.apache.lucene.queryParser
Class CompassQueryParser

java.lang.Object
  extended by org.apache.lucene.queryParser.QueryParser
      extended by org.apache.lucene.queryParser.CompassQueryParser
All Implemented Interfaces:
QueryParserConstants
Direct Known Subclasses:
SpellCheckQueryParser

public class CompassQueryParser
extends QueryParser

Extends Lucene QueryParser and overrides getRangeQuery(String,String,String,boolean) since lucene performs data parsing which is a performance killer. Anyhow, handling dates in Compass is different and simpler than Lucene.

Author:
kimchy

Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.lucene.queryParser.QueryParser
org.apache.lucene.queryParser.QueryParser.JJCalls, QueryParser.Operator
 
Field Summary
protected  CompassMapping mapping
           
protected  LuceneSearchEngineFactory searchEngineFactory
           
protected  boolean suggestedQuery
           
 
Fields inherited from class org.apache.lucene.queryParser.QueryParser
allowLeadingWildcard, analyzer, AND_OPERATOR, dateResolution, enablePositionIncrements, field, fieldToDateResolution, fuzzyMinSim, fuzzyPrefixLength, jj_nt, locale, lookingAhead, lowercaseExpandedTerms, OR_OPERATOR, phraseSlop, token, token_source, useOldRangeQuery
 
Fields inherited from interface org.apache.lucene.queryParser.QueryParserConstants
_ESCAPED_CHAR, _NUM_CHAR, _TERM_CHAR, _TERM_START_CHAR, _WHITESPACE, AND, Boost, CARAT, COLON, DEFAULT, EOF, FUZZY_SLOP, LPAREN, MINUS, NOT, NUMBER, OR, PLUS, PREFIXTERM, QUOTED, RangeEx, RANGEEX_END, RANGEEX_GOOP, RANGEEX_QUOTED, RANGEEX_START, RANGEEX_TO, RangeIn, RANGEIN_END, RANGEIN_GOOP, RANGEIN_QUOTED, RANGEIN_START, RANGEIN_TO, RPAREN, STAR, TERM, tokenImage, WILDTERM
 
Constructor Summary
CompassQueryParser(String f, Analyzer a, CompassMapping mapping, SearchEngineFactory searchEngineFactory, boolean forceAnalyzer)
           
 
Method Summary
 void close()
           
protected  Query getFieldQuery(String field, String queryText)
           
protected  Query getFuzzyQuery(String field, String termStr, float minSimilarity)
           
protected  Query getInternalFieldQuery(String field, String queryText)
           
protected  Query getPrefixQuery(String field, String termStr)
           
protected  Query getRangeQuery(String field, String part1, String part2, boolean inclusive)
          Override it so we won't use the date format to try and parse dates
protected  Term getTerm(String field, String text)
           
protected  Query getWildcardQuery(String field, String termStr)
           
 boolean isSuggestedQuery()
           
 void setAddAliasQueryWithDotPath(boolean addAliasQueryWithDotPath)
           
 void setAllowConstantScorePrefixQuery(boolean allowConstantScorePrefixQuery)
           
 
Methods inherited from class org.apache.lucene.queryParser.QueryParser
, addClause, Clause, Conjunction, disable_tracing, enable_tracing, escape, generateParseException, getAllowLeadingWildcard, getAnalyzer, getBooleanQuery, getBooleanQuery, getDateResolution, getDefaultOperator, getEnablePositionIncrements, getField, getFieldQuery, getFuzzyMinSim, getFuzzyPrefixLength, getLocale, getLowercaseExpandedTerms, getNextToken, getPhraseSlop, getToken, getUseOldRangeQuery, main, Modifiers, parse, Query, ReInit, ReInit, setAllowLeadingWildcard, setDateResolution, setDateResolution, setDefaultOperator, setEnablePositionIncrements, setFuzzyMinSim, setFuzzyPrefixLength, setLocale, setLowercaseExpandedTerms, setPhraseSlop, setUseOldRangeQuery, Term, TopLevelQuery
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mapping

protected final CompassMapping mapping

searchEngineFactory

protected final LuceneSearchEngineFactory searchEngineFactory

suggestedQuery

protected boolean suggestedQuery
Constructor Detail

CompassQueryParser

public CompassQueryParser(String f,
                          Analyzer a,
                          CompassMapping mapping,
                          SearchEngineFactory searchEngineFactory,
                          boolean forceAnalyzer)
Method Detail

setAllowConstantScorePrefixQuery

public void setAllowConstantScorePrefixQuery(boolean allowConstantScorePrefixQuery)

setAddAliasQueryWithDotPath

public void setAddAliasQueryWithDotPath(boolean addAliasQueryWithDotPath)

getWildcardQuery

protected Query getWildcardQuery(String field,
                                 String termStr)
                          throws ParseException
Overrides:
getWildcardQuery in class QueryParser
Throws:
ParseException

getFuzzyQuery

protected Query getFuzzyQuery(String field,
                              String termStr,
                              float minSimilarity)
                       throws ParseException
Overrides:
getFuzzyQuery in class QueryParser
Throws:
ParseException

getFieldQuery

protected Query getFieldQuery(String field,
                              String queryText)
                       throws ParseException
Overrides:
getFieldQuery in class QueryParser
Throws:
ParseException

getRangeQuery

protected Query getRangeQuery(String field,
                              String part1,
                              String part2,
                              boolean inclusive)
                       throws ParseException
Override it so we won't use the date format to try and parse dates

Overrides:
getRangeQuery in class QueryParser
Throws:
ParseException

getPrefixQuery

protected Query getPrefixQuery(String field,
                               String termStr)
                        throws ParseException
Overrides:
getPrefixQuery in class QueryParser
Throws:
ParseException

getInternalFieldQuery

protected Query getInternalFieldQuery(String field,
                                      String queryText)
                               throws ParseException
Throws:
ParseException - throw in overridden method to disallow

getTerm

protected Term getTerm(String field,
                       String text)
                throws ParseException
Throws:
ParseException

close

public void close()

isSuggestedQuery

public boolean isSuggestedQuery()


Copyright (c) 2004-2008 The Compass Project.