elastic

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2023 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DropIndices

func DropIndices()

func Index

func Index(items []IndexItem)

Types

type ElasticResult

type ElasticResult[T any] struct {
	// Milliseconds it took Elasticsearch to execute the request
	Took float64 `json:"took"`
	// Contains returned documents and metadata
	Hits struct {
		// Metadata about the number of matching documents
		Total struct {
			// Total number of matching documents
			Value float64 `json:"value"`
		} `json:"total"`
		// Array of returned document objects
		Hits []struct {
			// Name of the index containing the returned document
			Index string `json:"_index"`
			// Unique identifier for the returned document. This ID is only unique within the returned index.
			Id string `json:"_id"`
			// Positive 32-bit floating point number used to determine the relevance of the returned document
			Score float64 `json:"_score"`
			// Original JSON body passed for the document at index time
			Source T `json:"_source"`
		} `json:"hits"`
	} `json:"hits"`
}
func Search[T any](index string, query *map[string]any) ElasticResult[T]

type Host

type Host struct {
	Hostname string
	Username string
	Password string
}

type IndexFunc

type IndexFunc func(name string, key string, data any)

type IndexItem

type IndexItem struct {
	Name string
	Key  string
	Data any
}

type Indexer

type Indexer[T any] interface {
	Index(d T)
	Delete(key string)
	Find() ElasticResult[T]
}

type Mapping

type Mapping struct {
	Settings struct {
		NumberOfShards int `json:"number_of_shards"`
	} `json:"settings"`
	Mappings struct {
		Properties map[string]interface{} `json:"properties"`
	} `json:"mappings"`
}

Jump to

Keyboard shortcuts

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