ejsTermStatsFacet

A termsStatsFacet allows you to compute statistics over an aggregate key (term). Essentially this facet provides the functionality of what is often refered to as a pivot table.

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

 TermStatsFacet

TermStatsFacet ( name )

A facet which computes statistical data based on an aggregate key.


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

Allows you to return all terms, even if the frequency count is 0. This should not be used on fields that contain a large number of unique terms because it could cause out-of-memory errors.

ObjectcacheFilter(trueFalse)

Enables caching of the facetFilter

ObjectfacetFilter(oFilter)

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

Objectglobal(trueFalse)

Computes values across the entire index

ObjectkeyField(fieldName)Sets the field which will be used to pivot on (group-by).
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: count - default, sort by the number of items in the bucket term - sort by term value. reverse_count - reverse sort of the number of items in the bucket reverse_term - reverse sort of the term value. total - sorts by the total value of the bucket contents reverse_total - reverse sort of the total value of bucket contents min - the minimum value in the bucket reverse_min - the reverse sort of the minimum value max - the maximum value in the bucket reverse_max - the reverse sort of the maximum value mean - the mean value of the bucket contents reverse_mean - the reverse sort of the mean value of bucket contents.
Objectparams(oParams)Allows you to set script parameters to be used during the execution of the script.
Objectscope(scope)

Computes values across the the specified scope

ObjectscriptField(script)Sets a script that will provide the terms for a given document.
Objectsize(facetSize)Sets the number of facet entries that will be returned for this facet. For instance, you might ask for only the top 5 aggregate keys although there might be hundreds of unique keys. Higher settings could cause memory strain.
StringtoJSON()

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

ObjectvalueField(fieldName)Sets the field for which statistical information will be generated.
ObjectvalueScript(code)Define a script to evaluate of which the result will be used to generate the statistical information.

Method Detail

 _type

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

Returns
the type of object

 allTerms

Object allTerms ( trueFalse )

Allows you to return all terms, even if the frequency count is 0. This should not be used on fields that contain a large number of unique terms because it could cause out-of-memory errors.


Parameters
trueFalse <String> true or false
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.

 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.

 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.

 keyField

Object keyField ( fieldName )
Sets the field which will be used to pivot on (group-by).

Parameters
fieldName <String> The field name whose data will be used to construct the facet.
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: count - default, sort by the number of items in the bucket term - sort by term value. reverse_count - reverse sort of the number of items in the bucket reverse_term - reverse sort of the term value. total - sorts by the total value of the bucket contents reverse_total - reverse sort of the total value of bucket contents min - the minimum value in the bucket reverse_min - the reverse sort of the minimum value max - the maximum value in the bucket reverse_max - the reverse sort of the maximum value mean - the mean value of the bucket contents reverse_mean - the reverse sort of the mean value of bucket contents.

Parameters
o <String> The ordering method
Returns
returns this so that calls can be chained.

 params

Object params ( oParams )
Allows you to set script parameters to be used during the execution of the script.

Parameters
oParams <Object> An object containing key/value pairs representing param name/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.

 scriptField

Object scriptField ( script )
Sets a script that will provide the terms for a given document.

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

 size

Object size ( facetSize )
Sets the number of facet entries that will be returned for this facet. For instance, you might ask for only the top 5 aggregate keys although there might be hundreds of unique keys. Higher settings could cause memory strain.

Parameters
facetSize <Integer> The numer of facet entries to be returned.
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 )
Sets the field for which statistical information will be generated.

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

 valueScript

Object valueScript ( code )
Define a script to evaluate of which the result will be used to generate the statistical information.

Parameters
code <String> The script code to execute.
Returns
returns this so that calls can be chained.

Request

Queries

Filters

Aggregations

Facets

Suggesters

Geo