Class LuceneAutoCompleteHelpers
java.lang.Object
com.apple.foundationdb.record.lucene.LuceneAutoCompleteHelpers
This class provides some helpers for auto-complete functionality using Lucene auto complete suggestion lookup.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Helper class to capture token information synthesized from a search key. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncomputeAllMatches
(String fieldName, org.apache.lucene.analysis.Analyzer queryAnalyzer, String text, LuceneAutoCompleteHelpers.AutoCompleteTokens tokens, int numAdditionalTokens) computeAllMatchesForPhrase
(String fieldName, org.apache.lucene.analysis.Analyzer queryAnalyzer, String text, LuceneAutoCompleteHelpers.AutoCompleteTokens tokens, int numAdditionalTokens) static <M extends Message>
LuceneAnalyzerCombinationProvidergetAutoCompleteAnalyzerSelector
(FDBQueriedRecord<M> queriedRecord) static <M extends Message>
LuceneAnalyzerCombinationProvidergetAutoCompletedMatchesAnalyzerSelector
(FDBQueriedRecord<M> queriedRecord) getQueryTokens
(org.apache.lucene.analysis.Analyzer queryAnalyzer, String searchKey) Extract the query tokens from a string.static boolean
isPhraseSearch
(String search) static String
searchKeyFromSearchArgument
(String search) static String
searchKeyFromSearchArgument
(String search, boolean isPhraseSearch)
-
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 thetokens
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 thetokens
list. The final token will be returned by this method if and only if we are in the former case.- Parameters:
queryAnalyzer
- a query analyzersearchKey
- 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
-
searchKeyFromSearchArgument
-
searchKeyFromSearchArgument
-
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)
-