Class LuceneAutoCompleteHelpers

java.lang.Object
com.apple.foundationdb.record.lucene.LuceneAutoCompleteHelpers

public class LuceneAutoCompleteHelpers extends Object
This class provides some helpers for auto-complete functionality using Lucene auto complete suggestion lookup.
  • Constructor Details

    • LuceneAutoCompleteHelpers

      public LuceneAutoCompleteHelpers()
  • Method Details

    • getQueryTokens

      @Nonnull public static LuceneAutoCompleteHelpers.AutoCompleteTokens getQueryTokens(org.apache.lucene.analysis.Analyzer queryAnalyzer, String searchKey)
      Extract the query tokens from a string. All tokens (except the last one) are added to the tokens list. The last token is special. If the there is no whitespace following that token, this indicates that this is an incomplete prefix of a token that will be completed by the query. If there is whitespace following that token, then it is assumed that token is complete and is added to the tokens list. The final token will be returned by this method if and only if we are in the former case.
      Parameters:
      queryAnalyzer - a query analyzer
      searchKey - the phrase to find completions of
      Returns:
      the token info comprised of query tokens and a final token if it needs to be added as a "prefix" component to the final query
    • computeAllMatches

      @Nonnull public static List<String> computeAllMatches(@Nonnull String fieldName, @Nonnull org.apache.lucene.analysis.Analyzer queryAnalyzer, @Nonnull String text, @Nonnull LuceneAutoCompleteHelpers.AutoCompleteTokens tokens, int numAdditionalTokens)
    • computeAllMatchesForPhrase

      @Nonnull public static List<String> computeAllMatchesForPhrase(@Nonnull String fieldName, @Nonnull org.apache.lucene.analysis.Analyzer queryAnalyzer, @Nonnull String text, @Nonnull LuceneAutoCompleteHelpers.AutoCompleteTokens tokens, int numAdditionalTokens)
    • isPhraseSearch

      public static boolean isPhraseSearch(@Nonnull String search)
    • searchKeyFromSearchArgument

      @Nonnull public static String searchKeyFromSearchArgument(@Nonnull String search)
    • searchKeyFromSearchArgument

      @Nonnull public static String searchKeyFromSearchArgument(@Nonnull String search, boolean isPhraseSearch)
    • getAutoCompletedMatchesAnalyzerSelector

      @Nullable public static <M extends Message> LuceneAnalyzerCombinationProvider getAutoCompletedMatchesAnalyzerSelector(@Nullable FDBQueriedRecord<M> queriedRecord)
    • getAutoCompleteAnalyzerSelector

      @Nullable public static <M extends Message> LuceneAnalyzerCombinationProvider getAutoCompleteAnalyzerSelector(@Nullable FDBQueriedRecord<M> queriedRecord)