java.lang.Object
org.elasticsearch.search.sort.SortBuilder<ScriptSortBuilder>
org.elasticsearch.search.sort.ScriptSortBuilder
- All Implemented Interfaces:
NamedWriteable,VersionedNamedWriteable,Writeable,Rewriteable<SortBuilder<?>>,ToXContent,ToXContentObject
Script sort builder allows to sort based on a custom script expression.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface org.elasticsearch.xcontent.ToXContent
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.ParamsNested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V> -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final ParseFieldstatic final ParseFieldstatic final ParseFieldFields inherited from class org.elasticsearch.search.sort.SortBuilder
NESTED_FILTER_FIELD, NESTED_PATH_FIELD, order, ORDER_FIELDFields inherited from interface org.elasticsearch.index.query.Rewriteable
MAX_REWRITE_ROUNDSFields inherited from interface org.elasticsearch.xcontent.ToXContent
EMPTY_PARAMS -
Constructor Summary
ConstructorsConstructorDescriptionRead from a stream.ScriptSortBuilder(Script script, ScriptSortBuilder.ScriptSortType type) Constructs a script sort builder with the given script. -
Method Summary
Modifier and TypeMethodDescriptionbuild(SearchExecutionContext context) Create a SortFieldAndFormat from this builder.buildBucketedSort(SearchExecutionContext context, BigArrays bigArrays, int bucketSize, BucketedSort.ExtraData extra) Create a BucketedSort which is useful for sorting inside of aggregations.booleanstatic ScriptSortBuilderfromXContent(XContentParser parser, String elementName) The minimal version of the recipient this object can be sent toReturns theNestedSortBuilderReturns the name of the writeable objectinthashCode()Rewrites this instance based on the provided context.script()Get the script used in this sort.setNestedSort(NestedSortBuilder nestedSort) Sets theNestedSortBuilderto be used for fields that are inside a nested object.sortMode()Get the sort mode.Defines which distance to use for sorting in the case a document contains multiple values.
ForScriptSortBuilder.ScriptSortType.STRING, the set of possible values is restricted toSortMode.MINandSortMode.MAXtoXContent(XContentBuilder builder, ToXContent.Params builderParams) type()Get the type used in this sort.voidwriteTo(StreamOutput out) Write this into the StreamOutput.Methods inherited from class org.elasticsearch.search.sort.SortBuilder
buildSort, fromXContent, order, order, parseNestedFilter, resolveNested, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.elasticsearch.xcontent.ToXContentObject
isFragment
-
Field Details
-
NAME
- See Also:
-
TYPE_FIELD
-
SCRIPT_FIELD
-
SORTMODE_FIELD
-
-
Constructor Details
-
ScriptSortBuilder
Constructs a script sort builder with the given script.- Parameters:
script- The script to use.type- The type of the script, can beScriptSortBuilder.ScriptSortType.STRING,ScriptSortBuilder.ScriptSortType.NUMBERorScriptSortBuilder.ScriptSortType.VERSION
-
ScriptSortBuilder
Read from a stream.- Throws:
IOException
-
-
Method Details
-
writeTo
Description copied from interface:WriteableWrite this into the StreamOutput.- Throws:
IOException
-
script
Get the script used in this sort. -
type
Get the type used in this sort. -
sortMode
Defines which distance to use for sorting in the case a document contains multiple values.
ForScriptSortBuilder.ScriptSortType.STRING, the set of possible values is restricted toSortMode.MINandSortMode.MAX -
sortMode
Get the sort mode. -
getNestedSort
Returns theNestedSortBuilder -
setNestedSort
Sets theNestedSortBuilderto be used for fields that are inside a nested object. TheNestedSortBuildertakes 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 XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params builderParams) throws IOException - Throws:
IOException
-
fromXContent
- Parameters:
parser- the input parser. The state on the parser contained in this context will be changed as a side effect of this method callelementName- 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
Description copied from class:SortBuilderCreate a SortFieldAndFormat from this builder.- Specified by:
buildin classSortBuilder<ScriptSortBuilder>- Throws:
IOException
-
buildBucketedSort
public BucketedSort buildBucketedSort(SearchExecutionContext context, BigArrays bigArrays, int bucketSize, BucketedSort.ExtraData extra) throws IOException Description copied from class:SortBuilderCreate a BucketedSort which is useful for sorting inside of aggregations.- Specified by:
buildBucketedSortin classSortBuilder<ScriptSortBuilder>- Throws:
IOException
-
equals
-
hashCode
public int hashCode() -
getWriteableName
Description copied from interface:VersionedNamedWriteableReturns the name of the writeable object -
getMinimalSupportedVersion
Description copied from interface:VersionedNamedWriteableThe minimal version of the recipient this object can be sent to -
rewrite
Description copied from interface:RewriteableRewrites 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:
IOException
-