search

package
v0.0.0-...-890d60c Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2021 License: MIT Imports: 8 Imported by: 2

Documentation

Overview

Package search deals with all search queries going to elasticsearch, and returning their results

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dict

type Dict map[string]interface{}

Dict represents a key-value map which may be unmarshalled from a yaml document. It is unique in that it enforces all the keys to be strings (where the default behavior in the yaml package is to have keys be interface{}), and for any embedded objects it find it will decode them into Dicts instead of map[interface{}]interface{}

func (*Dict) UnmarshalYAML

func (d *Dict) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML is used to unmarshal a yaml string into the Dict. See the dict's doc string for more details on what it is used for

type Hit

type Hit struct {
	Index  string                 `json:"_index"`  // The index the hit came from
	Type   string                 `json:"_type"`   // The type the document is
	ID     string                 `json:"_id"`     // The unique id of the document
	Score  float64                `json:"_score"`  // The document's score relative to the search
	Source map[string]interface{} `json:"_source"` // The actual document
}

Hit describes one of the documents matched by a search

type HitInfo

type HitInfo struct {
	HitCount    uint64  `json:"total"`     // The total number of documents matched
	HitMaxScore float64 `json:"max_score"` // The maximum score of all the documents matched
	Hits        []Hit   `json:"hits"`      // The actual documents matched
}

HitInfo describes information in the Result related to the actual hits

type Result

type Result struct {
	TookMS       uint64                          `json:"took"`      // Time search took to complete, in milliseconds
	TimedOut     bool                            `json:"timed_out"` // Whether or not the search timed out
	HitInfo      `json:"hits" luautil:",inline"` // Information related to the actual hits
	Aggregations map[string]interface{}          `json:"aggregations"` // Information related to aggregations in the query
}

Result describes the returned data from a search

func Search(index, typ string, search interface{}) (Result, error)

Search performs a search against the given elasticsearch index for documents of the given type. The search must json marshal into a valid elasticsearch request body query (see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-body.html)

Jump to

Keyboard shortcuts

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