Kademi's abstraction over Elasticsearch SearchHit to enable pluggable implementations. SearchHit represents a single search result document.


Properties

PropertyReturnsDescription
fieldsMap<String,KSearchHitField>The fields explicitly requested for this hit (for example via a stored fields or docvalue fields clause), keyed by field name. Empty, never null, when the query did not request any fields.
idStringElasticsearch document id of this hit. Never null.
indexStringName of the Elasticsearch index this hit was retrieved from.
scorefloatRelevance score assigned to this hit by the search query, higher meaning a closer match. Zero when the query did not compute scores, for example a query sorted only by field value.
sourceMap<String,Object>The parsed source document for this hit as a map of field name to value, taken from the native hit when this wraps a real Elasticsearch result, or from the custom source map when this instance was built directly. Never null for a hit produced from a real search.
sourceAsMapMap<String,Object>The source document as a map of field name to value, as stored at index time. May be null when this hit was retrieved from a native Elasticsearch SearchHit that did not fetch the source.
sourceAsStringStringThe source document for this hit serialised as a JSON string, taken from the native hit when available or rendered from the custom source map otherwise.
typeStringElasticsearch mapping type of the indexed document that produced this hit.

Methods

getSource() · getId() · getType() · getIndex() · getScore() · getSourceAsMap() · getFields() · getField(String name) · getSourceAsString()

getSource()

Returns: Map<String,Object>

The parsed source document for this hit as a map of field name to value, taken from the native hit when this wraps a real Elasticsearch result, or from the custom source map when this instance was built directly. Never null for a hit produced from a real search.

getId()

Returns: String

Elasticsearch document id of this hit. Never null.

getType()

Returns: String

Elasticsearch mapping type of the indexed document that produced this hit.

getIndex()

Returns: String

Name of the Elasticsearch index this hit was retrieved from.

getScore()

Returns: float

Relevance score assigned to this hit by the search query, higher meaning a closer match. Zero when the query did not compute scores, for example a query sorted only by field value.

getSourceAsMap()

Returns: Map<String,Object>

The source document as a map of field name to value, as stored at index time. May be null when this hit was retrieved from a native Elasticsearch SearchHit that did not fetch the source.

getFields()

Returns: Map<String,KSearchHitField>

The fields explicitly requested for this hit (for example via a stored fields or docvalue fields clause), keyed by field name. Empty, never null, when the query did not request any fields.

getField(String name)

Returns: KSearchHitField

Looks up one of this hit's requested fields by name.

ParameterDescription
namethe field name to look up

getSourceAsString()

Returns: String

The source document for this hit serialised as a JSON string, taken from the native hit when available or rendered from the custom source map otherwise.

To get full access to the Kademi Hub existing customers can login here, or new customers can register here.