ejsTermsFacet

A facet which returns the N most frequent terms within a collection or set of collections. Term facets are useful for building constructs which allow users to refine search results by filtering on terms returned by the facet.

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.

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

Module

 TermsFacet

TermsFacet ( 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.
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

Objectexclude(exclude)

Allows you to filter out unwanted facet entries. When passed a single term, it is appended to the list of currently excluded terms. If passed an array, it overwrites all existing values.

ObjectexecutionHint(h)Sets the execution hint determines how the facet is computed. Currently only supported value is "map".
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. Set to _index to return a facet count of hits per _index the search was executed on.
Objectfields(aFieldName)Aggregate statistical info across a set of fields.
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.

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.
Objectparams(p)Sets parameters that will be applied to the script. Overwrites any existing params.
Objectregex(exp)

Allows you to only include facet entries matching a specified regular expression.

ObjectregexFlags(flags)

Allows you to set the regular expression flags to be used with the regex

Objectscope(scope)

Computes values across the the specified scope

Objectscript(scriptCode)Allows you modify the term using a script. The modified value is then used in the facet collection.
ObjectscriptField(script)Sets a script that will provide the terms for a given document.
ObjectshardSize(shardSize)Determines how many terms the coordinating node will request from each shard.
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 authors although there might be hundreds of unique authors.
StringtoJSON()

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


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.

 exclude

Object exclude ( exclude )

Allows you to filter out unwanted facet entries. When passed a single term, it is appended to the list of currently excluded terms. If passed an array, it overwrites all existing values.


Parameters
exclude <String | String[]> A single term to exclude or an array of terms to exclude.
Returns
returns this so that calls can be chained.

 executionHint

Object executionHint ( h )
Sets the execution hint determines how the facet is computed. Currently only supported value is "map".

Parameters
h <Object> The hint value 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 field to be used to construct the this facet. Set to _index to return a facet count of hits per _index the search was executed on.

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

 fields

Object fields ( aFieldName )
Aggregate statistical info across a set of fields.

Parameters
aFieldName <Array> An array of field names.
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.

 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.

Parameters
o <String> The ordering method
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.

 regex

Object regex ( exp )

Allows you to only include facet entries matching a specified regular expression.


Parameters
exp <String> A valid regular expression.
Returns
returns this so that calls can be chained.

 regexFlags

Object regexFlags ( flags )

Allows you to set the regular expression flags to be used with the regex


Parameters
flags <String> A valid regex flag - see Java Pattern API
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.

 script

Object script ( scriptCode )
Allows you modify the term using a script. The modified value is then used in the facet collection.

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

 shardSize

Object shardSize ( shardSize )
Determines how many terms the coordinating node will request from each shard.

Parameters
shardSize <Integer> The numer of terms to fetch from each shard.
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 authors although there might be hundreds of unique authors.

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.

Request

Queries

Filters

Aggregations

Facets

Suggesters

Geo