ejsTopHitsAggregation

A top_hits metric aggregator keeps track of the most relevant document being aggregated. This aggregator is intended to be used as a sub aggregator, so that the top matching documents can be aggregated per bucket.

Module

 TopHitsAggregation

TopHitsAggregation ( name )

top_hits metric aggregator keeps track of the most relevant document being aggregated.


Parameters
name <String> The name which be used to refer to this aggregation.

Method Summary

Returns Name Description
String_type()The type of ejs object. For internal use only.
Objectagg(agg)Add a nesated aggregation. This method can be called multiple times in order to set multiple nested aggregations what will be executed at the same time as the parent aggregation. Alias for the aggregation method.
Objectaggregation(agg)Add a nesated aggregation. This method can be called multiple times in order to set multiple nested aggregations what will be executed at the same time as the parent aggregation.
Objectexplain(trueFalse)

Enable/Disable explanation of score for each hi.

ObjectfieldDataFields(Fields)

Allows to return the field data representation of a field for each hit.

Objectfrom(from)

The offset from the first result you want to fetch.

Objecthighlight(h)

Performs highlighting based on the Highlight settings.

ObjectscriptField(oScriptField)

Computes a document property dynamically based on the supplied ScriptField.

Objectsize(size)

Sets the maximum number of top matching hits to return per bucket.

Objectsort(sort)

The maximum number of top matching hits to return per bucket.

Objectsource(includes,excludes)

Allows to control how the _source field is returned with every hit. By default operations return the contents of the _source field unless you have used the fields parameter or if the _source field is disabled. Set the includes parameter to false to completely disable returning the source field.

StringtoJSON()

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

ObjecttrackScores(trueFalse)

Enables score computation and tracking during sorting. By default, sorting scores are not computed.

Objectversion(trueFalse)

Enable/Disable returning version number for each hit.


Method Detail

 _type

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

Returns
the type of object

 agg

Object agg ( agg )
Add a nesated aggregation. This method can be called multiple times in order to set multiple nested aggregations what will be executed at the same time as the parent aggregation. Alias for the aggregation method.

Parameters
agg <Aggregation> Any valid Aggregation object.
Returns
returns this so that calls can be chained.

 aggregation

Object aggregation ( agg )
Add a nesated aggregation. This method can be called multiple times in order to set multiple nested aggregations what will be executed at the same time as the parent aggregation.

Parameters
agg <Aggregation> Any valid Aggregation object.
Returns
returns this so that calls can be chained.

 explain

Object explain ( trueFalse )

Enable/Disable explanation of score for each hi.


Parameters
trueFalse <Boolean> true to enable, false to disable
Returns
returns this so that calls can be chained.

 fieldDataFields

Object fieldDataFields ( Fields )

Allows to return the field data representation of a field for each hit.


Parameters
Fields <Array> to return field data representation for.
Returns
returns this so that calls can be chained.

 from

Object from ( from )

The offset from the first result you want to fetch.


Parameters
from <Integer> The offset from the first result you want to fetch.
Returns
returns this so that calls can be chained.

 highlight

Object highlight ( h )

Performs highlighting based on the Highlight settings.


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

 scriptField

Object scriptField ( oScriptField )

Computes a document property dynamically based on the supplied ScriptField.


Parameters
oScriptField <ScriptField> A valid ScriptField.
Returns
returns this so that calls can be chained.

 size

Object size ( size )

Sets the maximum number of top matching hits to return per bucket.


Parameters
size <Integer> The numer of aggregation entries to be returned per bucket.
Returns
returns this so that calls can be chained.

 sort

Object sort ( sort )

The maximum number of top matching hits to return per bucket.


Parameters
sort <Array> How to sort the the top matching hits
Returns
returns this so that calls can be chained.

 source

Object source ( includes, excludes )

Allows to control how the _source field is returned with every hit. By default operations return the contents of the _source field unless you have used the fields parameter or if the _source field is disabled. Set the includes parameter to false to completely disable returning the source field.


Parameters
includes <String | Boolean | String[]> The field or list of fields to include as array. Set to a boolean false to disable the source completely.
excludes <String | String[]> The optional field or list of fields to exclude.
Returns
returns this so that calls can be chained.

 toJSON

String toJSON ( )

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


Returns
returns this object's internal object.

 trackScores

Object trackScores ( trueFalse )

Enables score computation and tracking during sorting. By default, sorting scores are not computed.


Parameters
trueFalse <Boolean> If scores should be computed and tracked.
Returns
returns this so that calls can be chained.

 version

Object version ( trueFalse )

Enable/Disable returning version number for each hit.


Parameters
trueFalse <Boolean> true to enable, false to disable
Returns
returns this so that calls can be chained.

Request

Queries

Filters

Aggregations

Facets

Suggesters

Geo