public class FieldSortBuilder extends SortBuilder<FieldSortBuilder>
Writeable.Reader<V>, Writeable.Writer<V>
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.Params
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DOC_FIELD_NAME
special field name to sort by index order
|
static ParseField |
MISSING |
static java.lang.String |
NAME |
static ParseField |
SORT_MODE |
static ParseField |
UNMAPPED_TYPE |
NESTED_FILTER_FIELD, NESTED_PATH_FIELD, order, ORDER_FIELD
EMPTY_PARAMS
Constructor and Description |
---|
FieldSortBuilder(FieldSortBuilder template)
Copy constructor.
|
FieldSortBuilder(StreamInput in)
Read from a stream.
|
FieldSortBuilder(java.lang.String fieldName)
Constructs a new sort based on a document field.
|
Modifier and Type | Method and Description |
---|---|
SortFieldAndFormat |
build(QueryShardContext context)
Create a @link
SortFieldAndFormat from this builder. |
boolean |
equals(java.lang.Object other) |
static FieldSortBuilder |
fromXContent(QueryParseContext context,
java.lang.String fieldName)
|
java.lang.String |
getFieldName()
Returns the document field this sort should be based on.
|
QueryBuilder |
getNestedFilter()
Returns the nested filter that the nested objects should match with in
order to be taken into account for sorting.
|
java.lang.String |
getNestedPath()
Returns the nested path if sorting occurs in a field that is inside a
nested object.
|
java.lang.String |
getWriteableName()
Returns the name of the writeable object
|
int |
hashCode() |
java.lang.Object |
missing()
Returns the value used when a field is missing in a doc.
|
FieldSortBuilder |
missing(java.lang.Object missing)
Sets the value when a field is missing in a doc.
|
FieldSortBuilder |
setNestedFilter(QueryBuilder nestedFilter)
Sets the nested filter that the nested objects should match with in order
to be taken into account for sorting.
|
FieldSortBuilder |
setNestedPath(java.lang.String nestedPath)
Sets the nested path if sorting occurs on a field that is inside a nested
object.
|
SortMode |
sortMode()
Returns what values to pick in the case a document contains multiple
values for the targeted sort field.
|
FieldSortBuilder |
sortMode(SortMode sortMode)
Defines what values to pick in the case a document contains multiple
values for the targeted sort field.
|
XContentBuilder |
toXContent(XContentBuilder builder,
ToXContent.Params params) |
java.lang.String |
unmappedType()
Returns the type to use in case the current field is not mapped in an
index.
|
FieldSortBuilder |
unmappedType(java.lang.String type)
Set the type to use in case the current field is not mapped in an index.
|
void |
writeTo(StreamOutput out)
Write this into the StreamOutput.
|
buildSort, fromXContent, order, order, parseNestedFilter, resolveNested
buildAsBytes, buildAsBytes, toString, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
isFragment
public static final java.lang.String NAME
public static final ParseField MISSING
public static final ParseField SORT_MODE
public static final ParseField UNMAPPED_TYPE
public static final java.lang.String DOC_FIELD_NAME
public FieldSortBuilder(FieldSortBuilder template)
public FieldSortBuilder(java.lang.String fieldName)
fieldName
- The field name.public FieldSortBuilder(StreamInput in) throws java.io.IOException
java.io.IOException
public void writeTo(StreamOutput out) throws java.io.IOException
Writeable
java.io.IOException
public java.lang.String getFieldName()
public FieldSortBuilder missing(java.lang.Object missing)
public java.lang.Object missing()
public FieldSortBuilder unmappedType(java.lang.String type)
public java.lang.String unmappedType()
public FieldSortBuilder sortMode(SortMode sortMode)
The last two values are only applicable for number based fields.
public SortMode sortMode()
public FieldSortBuilder setNestedFilter(QueryBuilder nestedFilter)
public QueryBuilder getNestedFilter()
public FieldSortBuilder setNestedPath(java.lang.String nestedPath)
public java.lang.String getNestedPath()
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws java.io.IOException
java.io.IOException
public SortFieldAndFormat build(QueryShardContext context) throws java.io.IOException
SortBuilder
SortFieldAndFormat
from this builder.build
in class SortBuilder<FieldSortBuilder>
java.io.IOException
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String getWriteableName()
NamedWriteable
public static FieldSortBuilder fromXContent(QueryParseContext context, java.lang.String fieldName) throws java.io.IOException
context
- the input parse context. The state on the parser contained in this context will be changed as a side effect of this
method callfieldName
- 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 argumentjava.io.IOException