Interface SearchScope<E>

Type Parameters:
E - A supertype of all types in this scope.

public interface SearchScope<E>
Represents a set of types and the corresponding indexes.

The scope can be used for search, to build search-related objects (predicate, sort, projection, aggregation, ...), or to define the targeted entities/indexes when passing it to the session.

It can also be used to start large-scale operations, e.g. using a schemaManager(), a workspace() or a massIndexer().

  • Method Details

    • predicate

      Initiate the building of a search predicate.

      The predicate will only be valid for search queries created using this scope or another scope instance targeting the same indexes.

      Note this method is only necessary if you do not want to use lambda expressions, since you can define predicates with lambdas within the search query DSL, removing the need to create separate objects to represent the predicates.

      Returns:
      A predicate factory.
      See Also:
    • sort

      Initiate the building of a search sort.

      The sort will only be valid for search queries created using this scope or another scope instance targeting the same indexes. or a wider scope.

      Note this method is only necessary if you do not want to use lambda expressions, since you can define sorts with lambdas within the search query DSL, removing the need to create separate objects to represent the sorts.

      Returns:
      A sort factory.
      See Also:
    • projection

      Initiate the building of a search projection that will be valid for the indexes in this scope.

      The projection will only be valid for search queries created using this scope or another scope instance targeting the same indexes.

      Note this method is only necessary if you do not want to use lambda expressions, since you can SearchQuerySelectStep.select(Function) define projections with lambdas} within the search query DSL, removing the need to create separate objects to represent the projections.

      Returns:
      A projection factory.
      See Also:
    • aggregation

      Initiate the building of a search aggregation that will be valid for the indexes in this scope.

      The aggregation will only be usable in search queries created using this scope or another scope instance targeting the same indexes.

      Note this method is only necessary if you do not want to use lambda expressions, since you can SearchQueryOptionsStep.aggregation(AggregationKey, SearchAggregation) define aggregations with lambdas} within the search query DSL, removing the need to create separate objects to represent the aggregation.

      Returns:
      An aggregation factory.
      See Also:
    • schemaManager

      SearchSchemaManager schemaManager()
      Create a SearchSchemaManager for the indexes mapped to types in this scope, or to any of their sub-types.
      Returns:
      A SearchSchemaManager.
    • highlighter

      Initiate the building of a highlighter that will be valid for the indexes in this scope.

      The highlighter will only be valid for search queries created using this scope or another scope instance targeting the same indexes.

      Note this method is only necessary if you do not want to use lambda expressions, since you can define highlighters with lambdas within the search query DSL, removing the need to create separate objects to represent the projections.

      Returns:
      A highlighter factory.
    • workspace

      SearchWorkspace workspace()
      Create a SearchWorkspace for the indexes mapped to types in this scope, or to any of their sub-types.

      This method only works for single-tenant applications. If multi-tenancy is enabled, use workspace(String) instead.

      Returns:
      A SearchWorkspace.
    • workspace

      @Deprecated(forRemoval=true) SearchWorkspace workspace(String tenantId)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Use workspace(Object) instead.
      Create a SearchWorkspace for the indexes mapped to types in this scope, or to any of their sub-types.

      This method only works for multi-tenant applications. If multi-tenancy is disabled, use workspace() instead.

      Parameters:
      tenantId - The identifier of the tenant whose index content should be targeted.
      Returns:
      A SearchWorkspace.
    • workspace

      SearchWorkspace workspace(Object tenantId)
      Create a SearchWorkspace for the indexes mapped to types in this scope, or to any of their sub-types.

      This method only works for multi-tenant applications. If multi-tenancy is disabled, use workspace() instead.

      Parameters:
      tenantId - The identifier of the tenant whose index content should be targeted.
      Returns:
      A SearchWorkspace.
    • massIndexer

      MassIndexer massIndexer()
      Create a MassIndexer for the indexes mapped to types in this scope, or to any of their sub-types.

      This method primarily is intended for single-tenant applications. If multi-tenancy is enabled, consider using massIndexer(String)/massIndexer(Set) instead. In case this method is used in multi-tenant environment - MassIndexer for all configured tenants will be created.

      MassIndexer instances cannot be reused.

      Returns:
      A MassIndexer.
    • massIndexer

      @Deprecated(forRemoval=true) MassIndexer massIndexer(String tenantId)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Use massIndexer(Object) instead.
      Create a MassIndexer for the indexes mapped to types in this scope, or to any of their sub-types.

      This method only works for multi-tenant applications. If multi-tenancy is disabled, use massIndexer() instead.

      MassIndexer instances cannot be reused.

      Parameters:
      tenantId - The identifier of the tenant whose index content should be targeted.
      Returns:
      A MassIndexer.
    • massIndexer

      MassIndexer massIndexer(Object tenantId)
      Create a MassIndexer for the indexes mapped to types in this scope, or to any of their sub-types.

      This method only works for multi-tenant applications. If multi-tenancy is disabled, use massIndexer() instead.

      MassIndexer instances cannot be reused.

      Parameters:
      tenantId - The identifier of the tenant whose index content should be targeted.
      Returns:
      A MassIndexer.
    • massIndexer

      MassIndexer massIndexer(Set<?> tenantIds)
      Create a MassIndexer for the indexes mapped to types in this scope, or to any of their sub-types.

      This method works for both single- and multi-tenant applications. If multi-tenancy is disabled, simply keep the set of tenants empty.

      MassIndexer instances cannot be reused.

      Parameters:
      tenantIds - The tenants identifiers whose index content should be targeted. If empty, all tenants will be targeted.
      Returns:
      A MassIndexer.
    • includedTypes

      Set<? extends SearchIndexedEntity<? extends E>> includedTypes()
      Returns:
      A set containing one SearchIndexedEntity for each indexed entity in this scope.
    • extension

      <T> T extension(IndexScopeExtension<T> extension)
      Extend the current search scope with the given extension, resulting in an extended search scope offering backend-specific utilities.
      Type Parameters:
      T - The type of search scope provided by the extension.
      Parameters:
      extension - The extension to apply.
      Returns:
      The extended search scope.
      Throws:
      SearchException - If the extension cannot be applied (wrong underlying technology, ...).