Kademi's abstraction over Elasticsearch SearchHit to enable pluggable implementations. SearchHit represents a single search result document.
Properties
| Property | Returns | Description |
|---|---|---|
| fields | 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. |
| id | String | Elasticsearch document id of this hit. Never null. |
| index | String | Name of the Elasticsearch index this hit was retrieved from. |
| score | 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. |
| source | 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. |
| sourceAsMap | 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. |
| sourceAsString | 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. |
| type | String | Elasticsearch 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.
| Parameter | Description |
|---|---|
name | the 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.