ejsHistogramFacet

The histogram facet works with numeric data by building a histogram across intervals of the field values. Each value is rounded into an interval (or placed in a bucket), and statistics are provided per interval/bucket (count and 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

 HistogramFacet

HistogramFacet ( name )

A facet which returns the N most frequent terms within a collection or set of collections.


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.
ObjectcacheFilter(trueFalse)

Enables caching of the facetFilter

ObjectfacetFilter(oFilter)

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

Objectfield(fieldName)Sets the field to be used to construct the this facet.
Objectfrom(from)Sets the "from", "start", or lower bounds bucket. For example if you have a value of 1023, an interval of 100, and a from value of 1500, it will be placed into the 1500 bucket vs. the normal bucket of 1000.
Objectglobal(trueFalse)

Computes values across the entire index

Objectinterval(numericInterval)Sets the bucket interval used to calculate the distribution.
ObjectkeyField(fieldName)Allows you to specify a different key field to be used to group intervals.
ObjectkeyScript(scriptCode)Allows you modify the key field using a script. The modified value is then used to generate the interval.
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.

Objectorder(o)Sets the type of ordering that will be performed on the date buckets. Valid values are: key - the default, sort by the bucket's key value count - sort by the number of items in the bucket total - sort by the sum/total of the items in the bucket
Objectparams(p)Sets parameters that will be applied to the script. Overwrites any existing params.
Objectscope(scope)

Computes values across the the specified scope

ObjecttimeInterval(timeInterval)Sets the bucket interval used to calculate the distribution based on a time value such as "1d", "1w", etc.
Objectto(to)Sets the "to", "end", or upper bounds bucket. For example if you have a value of 1023, an interval of 100, and a to value of 900, it will be placed into the 900 bucket vs. the normal bucket of 1000.
StringtoJSON()

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

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

 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.

 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 field to be used to construct the this facet.

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

 from

Object from ( from )
Sets the "from", "start", or lower bounds bucket. For example if you have a value of 1023, an interval of 100, and a from value of 1500, it will be placed into the 1500 bucket vs. the normal bucket of 1000.

Parameters
from <Number> the lower bounds bucket value.
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.

 interval

Object interval ( numericInterval )
Sets the bucket interval used to calculate the distribution.

Parameters
numericInterval <Number> The bucket interval in which to group values.
Returns
returns this so that calls can be chained.

 keyField

Object keyField ( fieldName )
Allows you to specify a different key field to be used to group intervals.

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

 keyScript

Object keyScript ( scriptCode )
Allows you modify the key field using a script. The modified value is then used to generate the interval.

Parameters
scriptCode <String> A valid script string to execute.
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.

 order

Object order ( o )
Sets the type of ordering that will be performed on the date buckets. Valid values are: key - the default, sort by the bucket's key value count - sort by the number of items in the bucket total - sort by the sum/total of the items in the bucket

Parameters
o <String> The ordering method: key, count, or total.
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.

 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.

 timeInterval

Object timeInterval ( timeInterval )
Sets the bucket interval used to calculate the distribution based on a time value such as "1d", "1w", etc.

Parameters
timeInterval <Number> The bucket interval in which to group values.
Returns
returns this so that calls can be chained.

 to

Object to ( to )
Sets the "to", "end", or upper bounds bucket. For example if you have a value of 1023, an interval of 100, and a to value of 900, it will be placed into the 900 bucket vs. the normal bucket of 1000.

Parameters
to <Number> the upper bounds bucket value.
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.

 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