reader

package
v5.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 19, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Hit

type Hit struct {
	ID     string                 `json:"id"`
	Fields map[string]interface{} `json:"fields"`
}

Hit is used to represent a object Hit

type Item

type Item struct {
	Key         string                            `json:"key,omitempty"`
	KeyAsString string                            `json:"key-as-string,omitempty"`
	Aggs        map[string]*ItemAgg               `json:"aggs,omitempty"`
	Buckets     map[string][]*Item                `json:"buckets,omitempty"`
	Baselines   map[string]baseline.BaselineValue `json:"baselines,omitempty"`
}

Item is used to represent a calculated aggregate and it's sub-aggregate

func EnrichWithTotalHits

func EnrichWithTotalHits(item *Item, totalHits int64) *Item

EnrichWithTotalHits enrich an Item with a new key doc_count giving the total number of hits

func ParseAggs

func ParseAggs(item map[string]interface{}) *Item

ParseAggs parse the Aggregations part of an elasticsearch result It is used recursively to parse sub aggs

func (*Item) ToAbstractMap

func (item *Item) ToAbstractMap() (map[string]interface{}, error)

ToAbstractMap convert an Item in an abstract map[string]interface{}

type ItemAgg

type ItemAgg struct {
	Value interface{} `json:"value,omitempty"`
}

ItemAgg is used to represent a single aggregate value

type WidgetData

type WidgetData struct {
	Hits       []Hit `json:"hits"`
	Aggregates *Item `json:"aggregates"`
}

WidgetData is a standard api response format for fact

func Parse

func Parse(res *elastic.SearchResult) (*WidgetData, error)

Parse parse a elasticsearch SearchResult (hits and aggregations) and returns a WidgetData

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL