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 Details

  • Constructor Details

    • LuceneQuerySuggester

      public LuceneQuerySuggester(Path indexFolder, SuggestConfig suggestConfig, ModifiedTermsService modifiedTermsService, org.apache.lucene.analysis.CharArraySet stopWords)
      Constructor.
      Parameters:
      indexFolder - the parent folder for the specific suggesters
      suggestConfig - the full suggest configuration
      modifiedTermsService - service that provides mappings for modified terms
      stopWords - optional set of stopwords. may be null
  • Method Details

    • instrument

      public void instrument(Optional<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 interface Instrumentable
      Parameters:
      metricsRegistryAdapter - optional adapter
      tags - these "standard" tags should be used for all added sensors. More tags can be added.
    • isReady

      public boolean isReady()
      Specified by:
      isReady in interface QuerySuggester
      Returns:
      true if ready to serve suggestions
    • suggest

      public List<Suggestion> suggest(String term, int maxResults, Set<String> tags)
      Specified by:
      suggest in interface QuerySuggester
      Parameters:
      term - the term for which to get suggestions
      maxResults - the maximum number of suggestions to return
      tags - the group names used for filtering
      Returns:
      A list of suggestions for the given term
    • getLastIndexTime

      public Instant getLastIndexTime()
      Specified by:
      getLastIndexTime in interface QueryIndexer
      Returns:
      The time of the last successful indexing
    • index

      public CompletableFuture<Void> index(Iterable<SuggestRecord> suggestions)
      Specified by:
      index in interface QueryIndexer
      Parameters:
      suggestions - the suggestions to index
      Returns:
      future that is ready as soon as the indexation is done
    • close

      public void close() throws Exception
      Specified by:
      close in interface AutoCloseable
      Throws:
      Exception
    • ramBytesUsed

      public long ramBytesUsed()
      Specified by:
      ramBytesUsed in interface org.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 interface QuerySuggester
      Returns:
      amount of indexed records