Class LuceneQuerySuggester
java.lang.Object
de.cxp.ocs.smartsuggest.querysuggester.lucene.LuceneQuerySuggester
- All Implemented Interfaces:
Instrumentable
,QueryIndexer
,QuerySuggester
,AutoCloseable
,org.apache.lucene.util.Accountable
public class LuceneQuerySuggester
extends Object
implements QuerySuggester, QueryIndexer, org.apache.lucene.util.Accountable, Instrumentable
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
static final String
static final String
static final String
Deprecated.static final String
static final String
static final String
static final String
Fields inherited from interface org.apache.lucene.util.Accountable
NULL_ACCOUNTABLE
Fields inherited from interface de.cxp.ocs.smartsuggest.querysuggester.QuerySuggester
DEFAULT_MAXIMUM_RESULTS
-
Constructor Summary
ConstructorsConstructorDescriptionLuceneQuerySuggester
(Path indexFolder, SuggestConfig suggestConfig, ModifiedTermsService modifiedTermsService, org.apache.lucene.analysis.CharArraySet stopWords) Constructor for fresh suggester that in initialized in an empty folder.LuceneQuerySuggester
(Path indexFolder, SuggestConfig suggestConfig, ModifiedTermsService modifiedTermsService, org.apache.lucene.analysis.CharArraySet stopWords, Long modTime) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
void
destroy()
Destroys any resources created by this suggesterindex
(Iterable<SuggestRecord> suggestions, long modificationTime) void
instrument
(MeterRegistryAdapter metricsRegistryAdapter, Iterable<io.micrometer.core.instrument.Tag> tags) Optional meter registry (adapter that gives access to the actual meter-registry).boolean
isReady()
long
long
return amount of records indexed into this QuerySuggester.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.util.Accountable
getChildResources
Methods inherited from interface de.cxp.ocs.smartsuggest.querysuggester.QueryIndexer
getIndexModTime
Methods inherited from interface de.cxp.ocs.smartsuggest.querysuggester.QuerySuggester
suggest
-
Field Details
-
PAYLOAD_LABEL_KEY
Deprecated.UseCommonPayloadFields.PAYLOAD_LABEL_KEY
instead.- See Also:
-
BEST_MATCHES_GROUP_NAME
- See Also:
-
TYPO_MATCHES_GROUP_NAME
- See Also:
-
FUZZY_MATCHES_ONE_EDIT_GROUP_NAME
- See Also:
-
FUZZY_MATCHES_TWO_EDITS_GROUP_NAME
- See Also:
-
SHINGLE_MATCHES_GROUP_NAME
- See Also:
-
RELAXED_GROUP_NAME
- See Also:
-
SHARPENED_GROUP_NAME
- See Also:
-
-
Constructor Details
-
LuceneQuerySuggester
public LuceneQuerySuggester(Path indexFolder, SuggestConfig suggestConfig, ModifiedTermsService modifiedTermsService, org.apache.lucene.analysis.CharArraySet stopWords) Constructor for fresh suggester that in initialized in an empty folder. To recover the suggester, use the other constructor with the modTime of the according data.- Parameters:
indexFolder
- the parent folder for the specific suggesterssuggestConfig
- the full suggest configurationmodifiedTermsService
- service that provides mappings for modified termsstopWords
- optional set of stopwords. may be null
-
LuceneQuerySuggester
public LuceneQuerySuggester(Path indexFolder, SuggestConfig suggestConfig, ModifiedTermsService modifiedTermsService, org.apache.lucene.analysis.CharArraySet stopWords, Long modTime) Constructor.- Parameters:
indexFolder
- the parent folder for the specific suggesterssuggestConfig
- the full suggest configurationmodifiedTermsService
- service that provides mappings for modified termsstopWords
- optional set of stopwords. may be nullmodTime
- Value that only MUST be set, if the indexFolder already contains the indexed data. It MUST NOT be set, if the indexFolder is empty and does not contain data. This modTime relates to the data that is already in the indexFolder.
-
-
Method Details
-
instrument
public void instrument(MeterRegistryAdapter metricsRegistryAdapter, Iterable<io.micrometer.core.instrument.Tag> tags) Description copied from interface:Instrumentable
Optional meter registry (adapter that gives access to the actual meter-registry). If not available, no metrics should be measured.- Specified by:
instrument
in interfaceInstrumentable
- Parameters:
metricsRegistryAdapter
- optional adaptertags
- these "standard" tags should be used for all added sensors. More tags can be added.
-
isReady
public boolean isReady()- Specified by:
isReady
in interfaceQuerySuggester
- Returns:
- true if ready to serve suggestions
-
suggest
- Specified by:
suggest
in interfaceQuerySuggester
- Parameters:
term
- the term for which to get suggestionsmaxResults
- the maximum number of suggestions to returntags
- the group names used for filtering- Returns:
- A list of suggestions for the given term
-
index
- Specified by:
index
in interfaceQueryIndexer
- Parameters:
suggestions
- the suggestions to indexmodificationTime
- timestamp (millis) of the data origin- Returns:
- future that is ready as soon as the indexation is done
-
close
- Specified by:
close
in interfaceAutoCloseable
- Throws:
Exception
-
destroy
Description copied from interface:QuerySuggester
Destroys any resources created by this suggester- Specified by:
destroy
in interfaceQuerySuggester
- Throws:
Exception
-
ramBytesUsed
public long ramBytesUsed()- Specified by:
ramBytesUsed
in interfaceorg.apache.lucene.util.Accountable
-
recordCount
public long recordCount()Description copied from interface:QuerySuggester
return amount of records indexed into this QuerySuggester.- Specified by:
recordCount
in interfaceQuerySuggester
- Returns:
- amount of indexed records
-