Interface HighlightProjectionOptionsStep

All Superinterfaces:
HighlightProjectionFinalStep, ProjectionFinalStep<List<String>>

public interface HighlightProjectionOptionsStep extends HighlightProjectionFinalStep
The initial and final step in a highlight definition, where optional parameters can be set.
  • Method Details

    • highlighter

      HighlightProjectionOptionsStep highlighter(String highlighterName)
      Defines a name of a named highlighter to be used by this field projection.
      Parameters:
      highlighterName - The name of a highlighter defined on the query.
      Returns:
      A final step to finish the definition of a highlight projection.
      See Also:
    • single

      Deprecated.
      Use the collector(ProjectionCollector.Provider) instead, e.g. .collector(ProjectionCollector.single())
      Defines the projection as single-valued, i.e. returning String instead of List<String>.

      Can only be used when the highlighter that creates highlighted fragments for this projection is configured to return a single fragment at most, i.e. when .numberOfFragments(1) is applied to the highlighter. Otherwise, it will lead to an exception being thrown when the query is created.

      Returns:
      A final step in the highlight projection definition.
      See Also:
    • collector

      Defines the collector to apply to the highlighted strings.

      By default, highlighting results in a list List<String> of highlighted strings. This method allows changing the returned type to a different collection of strings, e.g. Set<String>/String[] or obtaining a single-valued projection (i.e. projectionCollectorProvider.isSingleValued () == true).

      Note: single-valued projections can only be used when the highlighter that creates highlighted fragments for this projection is configured to return a single fragment at most, i.e. when .numberOfFragments(1) is applied to the highlighter. Otherwise, it will lead to an exception being thrown when the query is created.

      Type Parameters:
      R - The type of the final result.
      Parameters:
      collector - The collector provider to apply to this projection.
      Returns:
      A final step in the highlight projection definition.
    • nullable

      @Incubating default ProjectionFinalStep<String> nullable()
      Defines the projection as single-valued, i.e. returning String instead of List<String>.

      Can only be used when the highlighter that creates highlighted fragments for this projection is configured to return a single fragment at most, i.e. when .numberOfFragments(1) is applied to the highlighter. Otherwise, it will lead to an exception being thrown when the query is created.

      Returns:
      A final step in the highlight projection definition.
      See Also:
    • optional

      Defines the projection as single-valued wrapped in an Optional, i.e. returning Optional<String> instead of List<String>.

      Can only be used when the highlighter that creates highlighted fragments for this projection is configured to return a single fragment at most, i.e. when .numberOfFragments(1) is applied to the highlighter. Otherwise, it will lead to an exception being thrown when the query is created.

      Returns:
      A final step in the highlight projection definition.
      See Also:
    • set

      Changes the collection accumulating the values to Set instead of List.
      Returns:
      A final step in the highlight projection definition.
    • sortedSet

      Changes the collection accumulating the values to SortedSet instead of List.
      Returns:
      A final step in the highlight projection definition.
    • sortedSet

      @Incubating default ProjectionFinalStep<SortedSet<String>> sortedSet(Comparator<String> comparator)
      Changes the collection accumulating the values to SortedSet instead of List.
      Parameters:
      comparator - The comparator to use for sorting strings within the set.
      Returns:
      A final step in the highlight projection definition.
    • array

      Changes the collection accumulating the values to String[] instead of List.
      Returns:
      A final step in the highlight projection definition.