Documentation
¶
Index ¶
- Variables
- func ExtractFieldFromHits[T any](field string, hits []types.Hit) (map[string]T, error)
- func ExtractFieldValue[T any](field string, fields map[string]json.RawMessage) (T, error)
- func ExtractSource[T any](doc json.RawMessage) (T, error)
- func ExtractSourceFromDocs[T any](docs []types.MgetResponseItem) ([]T, error)
- func ExtractSourceFromHits[T any](hits []types.Hit) ([]T, []types.FieldValue, error)
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func ExtractFieldFromHits ¶
ExtractFieldFromHits loops through the given hits array and extracts the `_source` field of each document as type `T`, returning the document sources as an array `[]T`. If there was an issue extracting any source, it will also return a non-nil error containing details.
func ExtractFieldValue ¶
ExtractFieldValue extracts the value of the given field from a hit's list of returned fields. If the field is not found or the value cannot be extracted, a non-nil error is returned.
func ExtractSource ¶
func ExtractSource[T any](doc json.RawMessage) (T, error)
ExtractSource extracts the `_source` field from a hit. A non-nil error is returned if the source cannot be extracted.
func ExtractSourceFromDocs ¶
func ExtractSourceFromDocs[T any](docs []types.MgetResponseItem) ([]T, error)
ExtractSourceFromDocs loops through the given docs array and extracts the `_source` field of each document as type `T`, returning the document sources as an array `[]T`. If there was an issue extracting any source, it will also return a non-nil error containing details.
func ExtractSourceFromHits ¶
ExtractSourceFromHits loops through the given hits array and extracts the `_source` field of each document as type `T`, returning the document sources as an array `[]T`. If there was an issue extracting any source, it will also return a non-nil error containing details. The sort value of the last hit will also be returned, which can be used for pagination if needed.
Types ¶
This section is empty.