org.hibernate.search.query.dsl.sort

## Interface SortContext

- All Known Implementing Classes:
    ConnectedSortContext

      public interface SortContext

  Author:
    Emmanuel Bernard emmanuel@hibernate.org, Yoann Rodiere

- - ### Method Summary

    All Methods Instance Methods Abstract Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `SortDistanceNoFieldContext` | `byDistance()` Order elements by distance.
    `SortFieldContext` | `byField(String fieldName)` Order elements by the value of a specific field.
    `SortFieldContext` | `byField(String fieldName, SortField.Type sortFieldType)` Deprecated. Using this method shouldn't be needed if your custom field bridges implement `MetadataProvidingFieldBridge`. Use `byField(String)` instead.
    `SortOrderTermination` | `byIndexOrder()` Order elements by their internal index order.
    `SortNativeContext` | `byNative(SortField sortField)` Order element using the native backend API for Lucene.
    `SortNativeContext` | `byNative(String fieldName, String sortFieldNativeDescription)` Order element using the native backend API for Elasticsearch.
    `SortScoreContext` | `byScore()` Order elements by their relevance score.

- - ### Method Detail

    - #### byScore

          SortScoreContext byScore()

      Order elements by their relevance score.

      The default order is descending, i.e. higher scores come first.

    - #### byIndexOrder

          SortOrderTermination byIndexOrder()

      Order elements by their internal index order.

    - #### byField

          SortFieldContext byField(String fieldName)

      Order elements by the value of a specific field.

      The default order is ascending.

      The sort field type will be determined automatically if possible, and an exception will be thrown if it is not possible. Automatically determining the type is impossible in particular if a custom field bridge is defined on the given field and if this bridge doesn't implement `MetadataProvidingFieldBridge`.

      Parameters:
        `fieldName` - The name of the index field to sort by
      Throws:
        `SearchException` - If the sort field type could not be automatically determined.
      See Also:
        `The alternative for numeric fields with custom field bridges that don't implement {@link MetadataProvidingFieldBridge}.`

    - #### byField

          @Deprecated
          SortFieldContext byField(String fieldName,
                                               SortField.Type sortFieldType)

      Deprecated. Using this method shouldn't be needed if your custom field bridges implement `MetadataProvidingFieldBridge`. Use `byField(String)` instead.
      Order elements by value of a specific field, with the sort field type provided.

      The default order is ascending.

      Note: using this method is only required when sorting on a field on which a custom field bridge that doesn't implement `MetadataProvidingFieldBridge` is defined. Otherwise, one may simply use `byField(String)`.

      Parameters:
        `fieldName` - The name of the index field to sort by
        `sortFieldType` - The sort field type

    - #### byDistance

          SortDistanceNoFieldContext byDistance()

      Order elements by distance.

      The default order is ascending, i.e. shorter distances come first.

      The distance is computed between the value of a field carrying coordinates (to be provided in the `next context`) and reference coordinates.

    - #### byNative

          SortNativeContext byNative(SortField sortField)

      Order element using the native backend API for Lucene.

      The sort order (ascending/descending) is defined in `sortField`

      Parameters:
        `sortField` - The sort field to be added to the sort list.

    - #### byNative

          SortNativeContext byNative(String fieldName,
                                     String sortFieldNativeDescription)

      Order element using the native backend API for Elasticsearch.
      Parameters:
        `fieldName` - The name of the index field to sort by
        `sortFieldNativeDescription` - The sort field description, as valid JSON. This may be a simple quoted string (e.g. "'asc'") or a JSON map (e.g. "{'key': 'value'}"). See Elasticsearch's documentation for information about the exact syntax.

Copyright © 2006-2017 Red Hat, Inc. All Rights Reserved