ejsSort

A Sort object that can be used in on the Request object to specify various types of sorting.

See http://www.elasticsearch.org/guide/reference/api/search/sort.html

Module

 Sort

Sort ( fieldName )

Defines a sort value


Parameters
fieldName <String> The fieldName to sort against. Defaults to _score if not specified.

Method Summary

Returns Name Description
String_type()The type of ejs object. For internal use only.
Objectasc()Sets the sort order to ascending (asc). Same as calling order('asc').
Objectdesc()Sets the sort order to descending (desc). Same as calling order('desc').
ObjectdistanceType(type)How to compute the distance. Can either be arc (better precision) or plane (faster). Defaults to arc. Valid during sort types: geo distance
Objectfield(f)Set's the field to sort on
ObjectgeoDistance(point)Enables sorting based on a distance from a GeoPoint
ObjectignoreUnmapped(trueFalse)Sets if the sort should ignore unmapped fields vs throwing an error. Valid during sort types: field
Objectlang(lang)Sets the script language. Valid during sort types: script
Objectmissing(m)Sets the value to use for missing fields. Valid values are: _last - to put documents with the field missing last _first - to put documents with the field missing first {String} - any string value to use as the sort value. Valid during sort types: field
Objectmode(m)Sets the sort mode. Valid values are:
min - sort by lowest value
max - sort by highest value
sum - sort by the sum of all values
avg - sort by the average of all values
Valid during sort types: field, geo distance
ObjectnestedFilter(oFilter)

Allows you to set a filter that nested objects must match in order to be considered during sorting.

Valid during sort types: field, geo distance
ObjectnestedPath(path)Sets the path of the nested object. Valid during sort types: field, geo distance
Objectnormalize(trueFalse)If the lat/long points should be normalized to lie within their respective normalized ranges. Normalized ranges are: lon = -180 (exclusive) to 180 (inclusive) range lat = -90 to 90 (both inclusive) range Valid during sort types: geo distance
Objectorder(o)Sets the sort order. Valid values are: asc - for ascending order desc - for descending order Valid during sort types: field, geo distance, and script
Objectparams(p)Sets parameters that will be applied to the script. Overwrites any existing params. Valid during sort types: script
Objectreverse(trueFalse)Sets the order with a boolean value. true = descending sort order false = ascending sort order Valid during sort types: field, geo distance, and script
Objectscript(scriptCode)Enables sorting based on a script.
StringtoJSON()Retrieves the internal script object. This is typically used by internal API functions so use with caution.
Objecttype(type)Sets the script sort type. Valid values are:
string - script return value is sorted as a string
number - script return value is sorted as a number
Valid during sort types: script
Objectunit(unit)Sets the distance unit. Valid values are "mi" for miles or "km" for kilometers. Defaults to "km". Valid during sort types: geo distance

Method Detail

 _type

String _type ( )
The type of ejs object. For internal use only.

Returns
the type of object

 asc

Object asc ( )
Sets the sort order to ascending (asc). Same as calling order('asc').

Returns
returns this so that calls can be chained.

 desc

Object desc ( )
Sets the sort order to descending (desc). Same as calling order('desc').

Returns
returns this so that calls can be chained.

 distanceType

Object distanceType ( type )
How to compute the distance. Can either be arc (better precision) or plane (faster). Defaults to arc. Valid during sort types: geo distance

Parameters
type <String> The execution type as a string.
Returns
returns this so that calls can be chained.

 field

Object field ( f )
Set's the field to sort on

Parameters
f <String> The name of a field
Returns
returns this so that calls can be chained.

 geoDistance

Object geoDistance ( point )
Enables sorting based on a distance from a GeoPoint

Parameters
point <GeoPoint> A valid GeoPoint object
Returns
returns this so that calls can be chained.

 ignoreUnmapped

Object ignoreUnmapped ( trueFalse )
Sets if the sort should ignore unmapped fields vs throwing an error. Valid during sort types: field

Parameters
trueFalse <Boolean> If sort should ignore unmapped fields.
Returns
returns this so that calls can be chained.

 lang

Object lang ( lang )
Sets the script language. Valid during sort types: script

Parameters
lang <String> The script language, default mvel.
Returns
returns this so that calls can be chained.

 missing

Object missing ( m )
Sets the value to use for missing fields. Valid values are: _last - to put documents with the field missing last _first - to put documents with the field missing first {String} - any string value to use as the sort value. Valid during sort types: field

Parameters
m <String> The value to use for documents with the field missing.
Returns
returns this so that calls can be chained.

 mode

Object mode ( m )
Sets the sort mode. Valid values are:
min - sort by lowest value
max - sort by highest value
sum - sort by the sum of all values
avg - sort by the average of all values
Valid during sort types: field, geo distance

Since
elasticsearch 0.90
Parameters
m <String> The sort mode. Either min, max, sum, or avg.
Returns
returns this so that calls can be chained.

 nestedFilter

Object nestedFilter ( oFilter )

Allows you to set a filter that nested objects must match in order to be considered during sorting.

Valid during sort types: field, geo distance

Since
elasticsearch 0.90
Parameters
oFilter <Object> A valid Filter object.
Returns
returns this so that calls can be chained.

 nestedPath

Object nestedPath ( path )
Sets the path of the nested object. Valid during sort types: field, geo distance

Since
elasticsearch 0.90
Parameters
path <String> The nested path value.
Returns
returns this so that calls can be chained.

 normalize

Object normalize ( trueFalse )
If the lat/long points should be normalized to lie within their respective normalized ranges. Normalized ranges are: lon = -180 (exclusive) to 180 (inclusive) range lat = -90 to 90 (both inclusive) range Valid during sort types: geo distance

Parameters
trueFalse <String> True if the coordinates should be normalized. False otherwise.
Returns
returns this so that calls can be chained.

 order

Object order ( o )
Sets the sort order. Valid values are: asc - for ascending order desc - for descending order Valid during sort types: field, geo distance, and script

Parameters
o <String> The sort order as a string, asc or desc.
Returns
returns this so that calls can be chained.

 params

Object params ( p )
Sets parameters that will be applied to the script. Overwrites any existing params. Valid during sort types: script

Parameters
p <Object> An object where the keys are the parameter name and values are the parameter value.
Returns
returns this so that calls can be chained.

 reverse

Object reverse ( trueFalse )
Sets the order with a boolean value. true = descending sort order false = ascending sort order Valid during sort types: field, geo distance, and script

Parameters
trueFalse <Boolean> If sort should be in reverse order.
Returns
returns this so that calls can be chained.

 script

Object script ( scriptCode )
Enables sorting based on a script.

Parameters
scriptCode <String> The script code as a string
Returns
returns this so that calls can be chained.

 toJSON

String toJSON ( )
Retrieves the internal script object. This is typically used by internal API functions so use with caution.

Returns
returns this object's internal object representation.

 type

Object type ( type )
Sets the script sort type. Valid values are:
string - script return value is sorted as a string
number - script return value is sorted as a number
Valid during sort types: script

Parameters
type <String> The sort type. Either string or number.
Returns
returns this so that calls can be chained.

 unit

Object unit ( unit )
Sets the distance unit. Valid values are "mi" for miles or "km" for kilometers. Defaults to "km". Valid during sort types: geo distance

Parameters
unit <Number> the unit of distance measure.
Returns
returns this so that calls can be chained.

Request

Queries

Filters

Aggregations

Facets

Suggesters

Geo