Package org.dlese.dpc.index.queryParser
Class ExtractorQueryParser
java.lang.Object
org.apache.lucene.queryParser.QueryParser
org.dlese.dpc.index.queryParser.ExtractorQueryParser
- All Implemented Interfaces:
org.apache.lucene.queryParser.QueryParserConstants
public class ExtractorQueryParser
extends org.apache.lucene.queryParser.QueryParser
A QueryParser for extracting terms and phrases from a given query. Note: this QueryParser does not return
a usable Query.
- Author:
- John Weatherley
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.lucene.queryParser.QueryParser
org.apache.lucene.queryParser.QueryParser.Operator -
Field Summary
Fields inherited from class org.apache.lucene.queryParser.QueryParser
AND_OPERATOR, jj_nt, OR_OPERATOR, token, token_sourceFields inherited from interface org.apache.lucene.queryParser.QueryParserConstants
_ESCAPED_CHAR, _NUM_CHAR, _QUOTED_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
ConstructorsConstructorDescriptionExtractorQueryParser(String defaultFieldInQuery, org.apache.lucene.analysis.Analyzer analyzer, String fieldToExtract) Constructor for the ExtractorQueryParser object -
Method Summary
Modifier and TypeMethodDescriptionstatic final StringGets a datestamp of the current time formatted for display with logs and output.String[]Gets the terms extracted from the given field after calling the parse method.protected org.apache.lucene.search.QuerygetFieldQuery(String field, String queryText) Gets the fieldQuery attribute of the ExtractorQueryParser objectstatic voidsetDebug(boolean db) Sets the debug attribute of the FieldQueryParser objectMethods 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, getFuzzyQuery, getLocale, getLowercaseExpandedTerms, getMultiTermRewriteMethod, getNextToken, getPhraseSlop, getPrefixQuery, getRangeCollator, getRangeQuery, getToken, getWildcardQuery, main, Modifiers, newBooleanClause, newBooleanQuery, newFuzzyQuery, newMatchAllDocsQuery, newMultiPhraseQuery, newPhraseQuery, newPrefixQuery, newRangeQuery, newTermQuery, newWildcardQuery, parse, Query, ReInit, ReInit, setAllowLeadingWildcard, setDateResolution, setDateResolution, setDefaultOperator, setEnablePositionIncrements, setFuzzyMinSim, setFuzzyPrefixLength, setLocale, setLowercaseExpandedTerms, setMultiTermRewriteMethod, setPhraseSlop, setRangeCollator, Term, TopLevelQuery
-
Constructor Details
-
ExtractorQueryParser
public ExtractorQueryParser(String defaultFieldInQuery, org.apache.lucene.analysis.Analyzer analyzer, String fieldToExtract) Constructor for the ExtractorQueryParser object- Parameters:
defaultFieldInQuery- The defult field in the query you are parsinganalyzer- The Analyzer to use when parsing the queryfieldToExtract- The field you wish to extract the terms from
-
-
Method Details
-
getFieldQuery
protected org.apache.lucene.search.Query getFieldQuery(String field, String queryText) throws org.apache.lucene.queryParser.ParseException Gets the fieldQuery attribute of the ExtractorQueryParser object- Overrides:
getFieldQueryin classorg.apache.lucene.queryParser.QueryParser- Parameters:
field- The field being processedqueryText- The text in the field- Returns:
- The fieldQuery value
- Throws:
org.apache.lucene.queryParser.ParseException- If error
-
getExtractedTerms
Gets the terms extracted from the given field after calling the parse method. All terms are included, whether they were from a phrase or not.- Returns:
- The extractedTerms or null;
-
getDateStamp
Gets a datestamp of the current time formatted for display with logs and output.- Returns:
- A datestamp for display purposes.
-
setDebug
public static void setDebug(boolean db) Sets the debug attribute of the FieldQueryParser object- Parameters:
db- The new debug value
-