Class LuceneOptimizedMultiFieldStopWordsQueryParser

java.lang.Object
org.apache.lucene.util.QueryBuilder
org.apache.lucene.queryparser.classic.QueryParserBase
org.apache.lucene.queryparser.classic.QueryParser
org.apache.lucene.queryparser.classic.MultiFieldQueryParser
com.apple.foundationdb.record.lucene.search.LuceneOptimizedMultiFieldQueryParser
com.apple.foundationdb.record.lucene.search.LuceneOptimizedMultiFieldStopWordsQueryParser
All Implemented Interfaces:
ConfigAwareQueryParser, org.apache.lucene.queryparser.classic.QueryParserConstants, org.apache.lucene.queryparser.flexible.standard.CommonQueryParserConfiguration

public class LuceneOptimizedMultiFieldStopWordsQueryParser extends LuceneOptimizedMultiFieldQueryParser
A QueryParser that changes the way by which stop words in the query are handled. Stop words are not indexed, which means that a query for +the will not match a document that has "the" in it (because of the "+" in the query and the fact that the "the" is not indexed). In the cases where users are adding search terms that are prefixes of stop words (e.g. +the*) we want to match documents that have suffixes of the stop words (e.g. "these") but not be blocked by the stop words themselves. As a result, this parser relaxes the query requirement (removed the "+") from stop words search terms. Note that normally, for search terms that are not prefix queries (ones that do not end with "*"), the analyzer will handle the stop words removal, so this is not necessary here.
  • Nested Class Summary

    Nested classes/interfaces inherited from class org.apache.lucene.queryparser.classic.QueryParser

    org.apache.lucene.queryparser.classic.QueryParser.Operator

    Nested classes/interfaces inherited from class org.apache.lucene.util.QueryBuilder

    org.apache.lucene.util.QueryBuilder.TermAndBoost
  • Field Summary

    Fields inherited from class org.apache.lucene.queryparser.classic.MultiFieldQueryParser

    boosts, fields

    Fields inherited from class org.apache.lucene.queryparser.classic.QueryParser

    DEFAULT_SPLIT_ON_WHITESPACE, jj_nt, token, token_source

    Fields inherited from class org.apache.lucene.queryparser.classic.QueryParserBase

    AND_OPERATOR, field, OR_OPERATOR

    Fields inherited from class org.apache.lucene.util.QueryBuilder

    analyzer, autoGenerateMultiTermSynonymsPhraseQuery, enableGraphQueries, enablePositionIncrements

    Fields inherited from interface org.apache.lucene.queryparser.classic.QueryParserConstants

    _ESCAPED_CHAR, _NUM_CHAR, _QUOTED_CHAR, _TERM_CHAR, _TERM_START_CHAR, _WHITESPACE, AND, BAREOPER, Boost, CARAT, COLON, DEFAULT, EOF, FUZZY_SLOP, LPAREN, MINUS, NOT, NUMBER, OR, PLUS, PREFIXTERM, QUOTED, Range, RANGE_GOOP, RANGE_QUOTED, RANGE_TO, RANGEEX_END, RANGEEX_START, RANGEIN_END, RANGEIN_START, REGEXPTERM, RPAREN, STAR, TERM, tokenImage, WILDTERM
  • Constructor Summary

    Constructors
    Constructor
    Description
    LuceneOptimizedMultiFieldStopWordsQueryParser(String[] fields, org.apache.lucene.analysis.Analyzer analyzer, Map<String,org.apache.lucene.queryparser.flexible.standard.config.PointsConfig> pointsConfig, org.apache.lucene.analysis.CharArraySet stopWords)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected org.apache.lucene.search.BooleanClause
    newBooleanClause(org.apache.lucene.search.Query q, org.apache.lucene.search.BooleanClause.Occur occur)
     

    Methods inherited from class org.apache.lucene.queryparser.classic.MultiFieldQueryParser

    getFuzzyQuery, getMultiFieldQuery, getPrefixQuery, getRegexpQuery, getWildcardQuery, parse, parse, parse

    Methods inherited from class org.apache.lucene.queryparser.classic.QueryParser

    Clause, Conjunction, disable_tracing, enable_tracing, generateParseException, getNextToken, getSplitOnWhitespace, getToken, Modifiers, MultiTerm, Query, ReInit, ReInit, setAutoGeneratePhraseQueries, setSplitOnWhitespace, Term, TopLevelQuery

    Methods inherited from class org.apache.lucene.queryparser.classic.QueryParserBase

    addClause, addMultiTermClauses, escape, getAllowLeadingWildcard, getAutoGeneratePhraseQueries, getBooleanQuery, getDateResolution, getDefaultOperator, getDeterminizeWorkLimit, getField, getFuzzyMinSim, getFuzzyPrefixLength, getLocale, getMultiTermRewriteMethod, getPhraseSlop, getTimeZone, init, newFieldQuery, newFuzzyQuery, newMatchAllDocsQuery, newPrefixQuery, newRangeQuery, newRegexpQuery, newWildcardQuery, parse, setAllowLeadingWildcard, setDateResolution, setDateResolution, setDefaultOperator, setDeterminizeWorkLimit, setFuzzyMinSim, setFuzzyPrefixLength, setLocale, setMultiTermRewriteMethod, setPhraseSlop, setTimeZone

    Methods inherited from class org.apache.lucene.util.QueryBuilder

    add, analyzeBoolean, analyzeGraphBoolean, analyzeGraphPhrase, analyzeMultiBoolean, analyzeMultiPhrase, analyzePhrase, analyzeTerm, createBooleanQuery, createBooleanQuery, createFieldQuery, createFieldQuery, createMinShouldMatchQuery, createPhraseQuery, createPhraseQuery, createSpanQuery, getAnalyzer, getAutoGenerateMultiTermSynonymsPhraseQuery, getEnableGraphQueries, getEnablePositionIncrements, newBooleanQuery, newGraphSynonymQuery, newMultiPhraseQueryBuilder, newSynonymQuery, newTermQuery, setAnalyzer, setAutoGenerateMultiTermSynonymsPhraseQuery, setEnableGraphQueries, setEnablePositionIncrements

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.apache.lucene.queryparser.flexible.standard.CommonQueryParserConfiguration

    getAnalyzer, getEnablePositionIncrements, setEnablePositionIncrements

    Methods inherited from interface com.apple.foundationdb.record.lucene.search.ConfigAwareQueryParser

    addSlop, attemptConstructFieldQueryWithPointsConfig, attemptConstructRangeQueryWithPointsConfig
  • Constructor Details

    • LuceneOptimizedMultiFieldStopWordsQueryParser

      public LuceneOptimizedMultiFieldStopWordsQueryParser(String[] fields, org.apache.lucene.analysis.Analyzer analyzer, @Nonnull Map<String,org.apache.lucene.queryparser.flexible.standard.config.PointsConfig> pointsConfig, @Nonnull org.apache.lucene.analysis.CharArraySet stopWords)
  • Method Details

    • newBooleanClause

      protected org.apache.lucene.search.BooleanClause newBooleanClause(org.apache.lucene.search.Query q, org.apache.lucene.search.BooleanClause.Occur occur)
      Overrides:
      newBooleanClause in class org.apache.lucene.queryparser.classic.QueryParserBase