Class JiraLuceneFieldFinder

java.lang.Object
com.atlassian.jira.issue.search.parameters.lucene.sort.JiraLuceneFieldFinder

@Internal public class JiraLuceneFieldFinder extends Object
This used to be a cache of values but it was found that it consumed a hell of a lot of memory for no benefit (JRA-10111). So the cache.put was never called.

This has been refactored into a "finder" of terms values for fields within documents.

Platform-specific class intended for the Lucene search platform only.

Jira Search exposes a common API backed by multiple search engines. This class bypasses that abstraction and couples callers to Lucene internals.

Using this class when the runtime search platform is not Lucene (e.g. OpenSearch) may produce incorrect results or failures.

Internal use only.

  • Constructor Details

    • JiraLuceneFieldFinder

      public JiraLuceneFieldFinder()
  • Method Details

    • getInstance

      public static JiraLuceneFieldFinder getInstance()
    • getCustom

      public Object[] getCustom(org.apache.lucene.index.IndexReader reader, String field, MappedSortComparator mappedSortComparator) throws IOException
      This is used to retrieve values from the Lucence index. It returns an array that is the same size as the number of documents in the reader and will have all null values if the field is not present, otherwise it has the values of the field within the document.
      Parameters:
      reader - the Lucence index reader
      field - the name of the field to find
      mappedSortComparator - the MappedSortComparator that we are acting on behalf of
      Returns:
      an non null array of values, which may contain null values.
      Throws:
      IOException - if things dont play out well.
    • getTermValuesForField

      public List<String> getTermValuesForField(org.apache.lucene.index.IndexReader reader, String field) throws IOException
      This method is used to retrieve term values form the Lucene index. It returns a list of the text representation of the terms that are present in a field - this list will be empty if a field has no terms.
      Parameters:
      reader - the Lucence index reader
      field - the name of the field to find
      Returns:
      a List of strings that represent the term values for a specified field
      Throws:
      IOException
    • getMatches

      public Collection<String>[] getMatches(org.apache.lucene.index.IndexReader reader, String field) throws IOException
      For each document in the index, it returns an array of string collections for each matching term. Uses the DefaultMatchHandler.
      Parameters:
      reader - the index to read
      field - the field to check the documents for
      Returns:
      an array of string collections for each term for each document
      Throws:
      IOException - if things dont play out well.
    • getUniqueMatches

      @ExperimentalApi public List<String>[] getUniqueMatches(org.apache.lucene.index.IndexReader reader, String field) throws IOException
      For each document in the index, it returns an array of string collections for each matching term. Uses the SingleValueMatchHandler, so any collections that are returned are guaranteed to contain exactly one (possibly null) value in them.
      Parameters:
      reader - the index to read
      field - the field to check the documents for
      Returns:
      an array of string collections for each term for each document
      Throws:
      IOException - if things dont play out well.
    • getMatches

      @ExperimentalApi public void getMatches(org.apache.lucene.index.IndexReader reader, String field, MatchHandler handler) throws IOException
      For each document that has at least one value defined for the specified field, invokes MatchHandler.handleMatchedDocument(int, String) with the document index and the field value as the argument.
      Parameters:
      reader - the index to read
      field - the field to check the documents for
      handler - a handler that will be invoked for each matching term
      Throws:
      IOException - if things dont play out well.