ejsGeoDistanceFacet

The geoDistanceFacet facet provides information over a range of distances from a provided point. This includes the number of hits that fall within each range, along with aggregate information (like total).

Facets are similar to SQL GROUP BY statements but perform much better. You can also construct several "groups" at once by simply specifying multiple facets.

Tip: For more information on faceted navigation, see this Wikipedia article on Faceted Classification.

Module

 GeoDistanceFacet

GeoDistanceFacet ( name )

A facet which provides information over a range of distances from a provided point.


Parameters
name <String> The name which be used to refer to this facet. For instance, the facet itself might utilize a field named doc_authors. Setting name to Authors would allow you to refer to the facet by that name, possibly simplifying some of the display logic.

Method Summary

Returns Name Description
String_type()The type of ejs object. For internal use only.
ObjectaddRange(from,to)Adds a new bounded range.
ObjectaddUnboundedFrom(from)Adds a new unbounded lower limit.
ObjectaddUnboundedTo(to)Adds a new unbounded upper limit.
ObjectcacheFilter(trueFalse)

Enables caching of the facetFilter

ObjectdistanceType(type)How to compute the distance. Can either be arc (better precision) or plane (faster). Defaults to arc.
ObjectfacetFilter(oFilter)

Allows you to reduce the documents used for computing facet results.

Objectfield(fieldName)Sets the document field containing the geo-coordinate to be used to calculate the distance. Defaults to "location".
Objectglobal(trueFalse)

Computes values across the entire index

Objectlang(language)The script language being used. Currently supported values are javascript, groovy, and mvel.
Objectmode(m)

Sets the mode the facet will use.

collector
post
Objectnested(path)

Sets the path to the nested document if faceting against a nested field.

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
Objectparams(p)Sets parameters that will be applied to the script. Overwrites any existing params.
Objectpoint(p)Sets the point of origin from where distances will be measured.
Objectscope(scope)

Computes values across the the specified scope

StringtoJSON()

Retrieves the internal facet object. This is typically used by internal API functions so use with caution.

Objectunit(unit)Sets the distance unit. Valid values are "mi" for miles or "km" for kilometers. Defaults to "km".
ObjectvalueField(fieldName)Allows you to specify a different value field to aggrerate over.
ObjectvalueScript(scriptCode)Allows you modify the value field using a script. The modified value is then used to compute the statistical data.

Method Detail

 _type

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

Returns
the type of object

 addRange

Object addRange ( from, to )
Adds a new bounded range.

Parameters
from <Number> The lower bound of the range
to <Number> The upper bound of the range
Returns
returns this so that calls can be chained.

 addUnboundedFrom

Object addUnboundedFrom ( from )
Adds a new unbounded lower limit.

Parameters
from <Number> The lower limit of the unbounded range
Returns
returns this so that calls can be chained.

 addUnboundedTo

Object addUnboundedTo ( to )
Adds a new unbounded upper limit.

Parameters
to <Number> The upper limit of the unbounded range
Returns
returns this so that calls can be chained.

 cacheFilter

Object cacheFilter ( trueFalse )

Enables caching of the facetFilter


Parameters
trueFalse <Boolean> If the facetFilter should be cached or not
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.

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

 facetFilter

Object facetFilter ( oFilter )

Allows you to reduce the documents used for computing facet results.


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

 field

Object field ( fieldName )
Sets the document field containing the geo-coordinate to be used to calculate the distance. Defaults to "location".

Parameters
fieldName <String> The field name whose data will be used to construct the facet.
Returns
returns this so that calls can be chained.

 global

Object global ( trueFalse )

Computes values across the entire index


Parameters
trueFalse <Boolean> Calculate facet counts globally or not.
Returns
returns this so that calls can be chained.

 lang

Object lang ( language )
The script language being used. Currently supported values are javascript, groovy, and mvel.

Parameters
language <String> The language of the script.
Returns
returns this so that calls can be chained.

 mode

Object mode ( m )

Sets the mode the facet will use.

collector
post

Parameters
m <String> The mode: collector or post.
Returns
returns this so that calls can be chained.

 nested

Object nested ( path )

Sets the path to the nested document if faceting against a nested field.


Parameters
path <String> The nested path
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

Parameters
trueFalse <String> True if the coordinates should be normalized. False otherwise.
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.

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.

 point

Object point ( p )
Sets the point of origin from where distances will be measured.

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

 scope

Object scope ( scope )

Computes values across the the specified scope


Deprecated
since elasticsearch 0.90
Parameters
scope <String> The scope name to calculate facet counts with.
Returns
returns this so that calls can be chained.

 toJSON

String toJSON ( )

Retrieves the internal facet object. This is typically used by internal API functions so use with caution.


Returns
returns this object's internal facet property.

 unit

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

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

 valueField

Object valueField ( fieldName )
Allows you to specify a different value field to aggrerate over.

Parameters
fieldName <String> The name of the field to be used.
Returns
returns this so that calls can be chained.

 valueScript

Object valueScript ( scriptCode )
Allows you modify the value field using a script. The modified value is then used to compute the statistical data.

Parameters
scriptCode <String> A valid script string to execute.
Returns
returns this so that calls can be chained.

Request

Queries

Filters

Aggregations

Facets

Suggesters

Geo