Class ScriptSortBuilder

java.lang.Object
org.elasticsearch.search.sort.SortBuilder<ScriptSortBuilder>
org.elasticsearch.search.sort.ScriptSortBuilder
All Implemented Interfaces:
NamedWriteable, Writeable, org.elasticsearch.common.xcontent.ToXContent, org.elasticsearch.common.xcontent.ToXContentObject, Rewriteable<SortBuilder<?>>

public class ScriptSortBuilder
extends SortBuilder<ScriptSortBuilder>
Script sort builder allows to sort based on a custom script expression.
  • Field Details

    • NAME

      public static final java.lang.String NAME
      See Also:
      Constant Field Values
    • TYPE_FIELD

      public static final org.elasticsearch.common.ParseField TYPE_FIELD
    • SCRIPT_FIELD

      public static final org.elasticsearch.common.ParseField SCRIPT_FIELD
    • SORTMODE_FIELD

      public static final org.elasticsearch.common.ParseField SORTMODE_FIELD
  • Constructor Details

  • Method Details

    • writeTo

      public void writeTo​(StreamOutput out) throws java.io.IOException
      Description copied from interface: Writeable
      Write this into the StreamOutput.
      Throws:
      java.io.IOException
    • script

      public Script script()
      Get the script used in this sort.
    • type

      Get the type used in this sort.
    • sortMode

      public ScriptSortBuilder sortMode​(SortMode sortMode)
      Defines which distance to use for sorting in the case a document contains multiple values.
      For ScriptSortBuilder.ScriptSortType.STRING, the set of possible values is restricted to SortMode.MIN and SortMode.MAX
    • sortMode

      public SortMode sortMode()
      Get the sort mode.
    • setNestedFilter

      @Deprecated public ScriptSortBuilder setNestedFilter​(QueryBuilder nestedFilter)
      Deprecated.
      set nested sort with setNestedSort(NestedSortBuilder) and retrieve with getNestedSort()
      Sets the nested filter that the nested objects should match with in order to be taken into account for sorting.
    • getNestedFilter

      @Deprecated public QueryBuilder getNestedFilter()
      Deprecated.
      set nested sort with setNestedSort(NestedSortBuilder) and retrieve with getNestedSort()
      Gets the nested filter.
    • setNestedPath

      @Deprecated public ScriptSortBuilder setNestedPath​(java.lang.String nestedPath)
      Deprecated.
      set nested sort with setNestedSort(NestedSortBuilder) and retrieve with getNestedSort()
      Sets the nested path if sorting occurs on a field that is inside a nested object. For sorting by script this needs to be specified.
    • getNestedPath

      @Deprecated public java.lang.String getNestedPath()
      Deprecated.
      set nested sort with setNestedSort(NestedSortBuilder) and retrieve with getNestedSort()
      Gets the nested path.
    • getNestedSort

      public NestedSortBuilder getNestedSort()
      Returns the NestedSortBuilder
    • setNestedSort

      public ScriptSortBuilder setNestedSort​(NestedSortBuilder nestedSort)
      Sets the NestedSortBuilder to be used for fields that are inside a nested object. The NestedSortBuilder takes a `path` argument and an optional nested filter that the nested objects should match with in order to be taken into account for sorting.
    • toXContent

      public org.elasticsearch.common.xcontent.XContentBuilder toXContent​(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params builderParams) throws java.io.IOException
      Throws:
      java.io.IOException
    • fromXContent

      public static ScriptSortBuilder fromXContent​(org.elasticsearch.common.xcontent.XContentParser parser, java.lang.String elementName)
      Creates a new ScriptSortBuilder from the query held by the XContentParser in XContent format.
      Parameters:
      parser - the input parser. The state on the parser contained in this context will be changed as a side effect of this method call
      elementName - in some sort syntax variations the field name precedes the xContent object that specifies further parameters, e.g. in '{ "foo": { "order" : "asc"} }'. When parsing the inner object, the field name can be passed in via this argument
    • build

      public SortFieldAndFormat build​(SearchExecutionContext context) throws java.io.IOException
      Description copied from class: SortBuilder
      Create a SortFieldAndFormat from this builder.
      Specified by:
      build in class SortBuilder<ScriptSortBuilder>
      Throws:
      java.io.IOException
    • buildBucketedSort

      public BucketedSort buildBucketedSort​(SearchExecutionContext context, BigArrays bigArrays, int bucketSize, BucketedSort.ExtraData extra) throws java.io.IOException
      Description copied from class: SortBuilder
      Create a BucketedSort which is useful for sorting inside of aggregations.
      Specified by:
      buildBucketedSort in class SortBuilder<ScriptSortBuilder>
      Throws:
      java.io.IOException
    • equals

      public boolean equals​(java.lang.Object object)
      Overrides:
      equals in class java.lang.Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class java.lang.Object
    • getWriteableName

      public java.lang.String getWriteableName()
      Description copied from interface: NamedWriteable
      Returns the name of the writeable object
    • rewrite

      public ScriptSortBuilder rewrite​(QueryRewriteContext ctx) throws java.io.IOException
      Description copied from interface: Rewriteable
      Rewrites this instance based on the provided context. The returned objects will be the same instance as this if no changes during the rewrite were applied.
      Throws:
      java.io.IOException