org.apache.lucene.queryParser
Class CompassMultiFieldQueryParser

java.lang.Object
  extended by org.apache.lucene.queryParser.QueryParser
      extended by org.apache.lucene.queryParser.MultiFieldQueryParser
          extended by org.apache.lucene.queryParser.CompassMultiFieldQueryParser
All Implemented Interfaces:
QueryParserConstants
Direct Known Subclasses:
SpellCheckMultiFieldQueryParser

public class CompassMultiFieldQueryParser
extends MultiFieldQueryParser

Extends Lucene MultiFieldQueryParser 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.MultiFieldQueryParser
boosts, fields
 
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
CompassMultiFieldQueryParser(String[] fields, Analyzer analyzer, 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.MultiFieldQueryParser
getFieldQuery, parse, parse, parse
 
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, 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

searchEngineFactory

protected final LuceneSearchEngineFactory searchEngineFactory

mapping

protected final CompassMapping mapping

suggestedQuery

protected boolean suggestedQuery
Constructor Detail

CompassMultiFieldQueryParser

public CompassMultiFieldQueryParser(String[] fields,
                                    Analyzer analyzer,
                                    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 MultiFieldQueryParser
Throws:
ParseException

getFuzzyQuery

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

getFieldQuery

protected Query getFieldQuery(String field,
                              String queryText)
                       throws ParseException
Overrides:
getFieldQuery in class MultiFieldQueryParser
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 MultiFieldQueryParser
Throws:
ParseException

getPrefixQuery

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

getInternalFieldQuery

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

close

public void close()

getTerm

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

isSuggestedQuery

public boolean isSuggestedQuery()


Copyright (c) 2004-2008 The Compass Project.