Class MatchRegionRetriever

java.lang.Object
org.apache.lucene.search.matchhighlight.MatchRegionRetriever

public class MatchRegionRetriever extends Object
Utility class to compute a list of "match regions" for a given query, searcher and document(s) using Matches API.
  • Field Details

  • Constructor Details

    • MatchRegionRetriever

      public MatchRegionRetriever(IndexSearcher searcher, Query query, Analyzer analyzer, Predicate<String> fieldsToLoadUnconditionally, Predicate<String> fieldsToLoadIfWithHits) throws IOException
      This constructor uses the default offset strategy supplier from computeOffsetRetrievalStrategies(IndexReader, Analyzer).
      Parameters:
      searcher - The IndexSearcher used to execute the query. The index searcher's task executor is also used for computing highlights concurrently.
      query - The query for which highlights should be returned.
      analyzer - An analyzer that may be used to reprocess (retokenize) document fields in the absence of position offsets in the index. Note that the analyzer must return tokens (positions and offsets) identical to the ones stored in the index.
      fieldsToLoadUnconditionally - A custom predicate that should return true for any field that should be preloaded and made available through MatchRegionRetriever.FieldValueProvider, regardless of whether the query affected the field or not. This predicate can be used to load additional fields during field highlighting, making them available to MatchRegionRetriever.MatchOffsetsConsumers.
      fieldsToLoadIfWithHits - A custom predicate that should return true for fields that should be highlighted. Typically, this would always return true indicating any field affected by the query should be highlighted. However, sometimes highlights may not be needed: for example, if they affect fields that are only used for filtering purposes. Returning false for such fields saves the costs of loading those fields into memory and scanning through field matches.
      Throws:
      IOException
    • MatchRegionRetriever

      public MatchRegionRetriever(IndexSearcher searcher, Query query, OffsetsRetrievalStrategySupplier fieldOffsetStrategySupplier, Predicate<String> fieldsToLoadUnconditionally, Predicate<String> fieldsToLoadIfWithHits) throws IOException
      Parameters:
      searcher - The IndexSearcher used to execute the query. The index searcher's task executor is also used for computing highlights concurrently.
      query - The query for which matches should be retrieved. The query should be rewritten against the provided searcher.
      fieldOffsetStrategySupplier - A custom supplier of per-field OffsetsRetrievalStrategy instances.
      fieldsToLoadUnconditionally - A custom predicate that should return true for any field that should be preloaded and made available through MatchRegionRetriever.FieldValueProvider, regardless of whether the query affected the field or not. This predicate can be used to load additional fields during field highlighting, making them available to MatchRegionRetriever.MatchOffsetsConsumers.
      fieldsToLoadIfWithHits - A custom predicate that should return true for fields that should be highlighted. Typically, this would always return true indicating any field affected by the query should be highlighted. However, sometimes highlights may not be needed: for example, if they affect fields that are only used for filtering purposes. Returning false for such fields saves the costs of loading those fields into memory and scanning through field matches.
      Throws:
      IOException
  • Method Details