elastic

package
v0.0.0-...-68ec1c9 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2024 License: Unlicense Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Host                 = "http://127.0.0.1:9200"
	ItemsNoDescIndexName = "items_no_desc"
	DebugPrint           = true
)

Variables

This section is empty.

Functions

func BuildBulkBody

func BuildBulkBody(obs ...interface{}) (bulk []byte)

func BulkIndex

func BulkIndex(itemsTotal int, items []*item.Item) error

func Call

func Call(method, url string, body []byte) (respBody []byte, statusCode int, err error)

func CreateIndex

func CreateIndex()

func Index

func Index(a IndexArgs)

func KagomeV2Tokenizer

func KagomeV2Tokenizer() *tokenizer.Tokenizer

func Refresh

func Refresh(index string)

func ToJSON

func ToJSON(o interface{}) []byte

func ToPrettyJSON

func ToPrettyJSON(o interface{}) []byte

Types

type Aggs

type Aggs struct {
	DocCountErrorUpperBound int `json:"doc_count_error_upper_bound"` // : 0,
	SumOtherDocCount        int `json:"sum_other_doc_count"`         // : 0,
	Buckets                 []struct {
		Key      interface{} `json:"key"`
		DocCount int         `json:"doc_count"`
	} `json:"buckets"`
}

type AttributeFacet

type AttributeFacet struct {
	AttributeOptionPair string
	Count               int
}

type CategoryFacet

type CategoryFacet struct {
	CategoryID int
	Count      int
}

type Conditions

type Conditions struct {
	Keyword     string
	CategoryIDs []int
	Statuses    []item.Status
	Attributes  []*attribute.AttributeCondition
}

type ESIndexStats

type ESIndexStats struct {
	All struct {
		Primaries struct {
			Docs struct {
				Count int64 `json:"count"`
			} `json:"docs"`
			Store struct {
				SizeInBytes             int64 `json:"size_in_bytes"`
				TotalDataSetSizeInBytes int64 `json:"total_data_set_size_in_bytes"`
			} `json:"store"`
			QueryCache struct {
				CacheCount     int64 `json:"cache_count"`
				CacheSize      int64 `json:"cache_size"`
				Evictions      int64 `json:"evictions"`
				HitCount       int64 `json:"hit_count"`
				MemSizeInBytes int64 `json:"memory_size_in_bytes"`
				MissCount      int64 `json:"miss_count"`
				TotalCount     int64 `json:"total_count"`
			} `json:"query_cache"`
			RequestCache struct {
				Evictions      int64 `json:"evictions"`
				HitCount       int64 `json:"hit_count"`
				MemSizeInBytes int64 `json:"memory_size_in_bytes"`
				MissCount      int64 `json:"miss_count"`
			} `json:"request_cache"`
		} `json:"primaries"`
	} `json:"_all"`
}

func IndexStats

func IndexStats(index string) *ESIndexStats

type IndexArgs

type IndexArgs struct {
	Dir          string
	PrefixFilter string
	BatchSize    int
	Max          int
	ConvertIDs   map[string]int // UUID => int ID
}

type Map

type Map = map[string]interface{}

type QueryArgs

type QueryArgs struct {
	C                *Conditions
	DoNotFetchSource bool
	From             int
	Size             int
	CategoryFacets   bool
	AttributeFacets  bool
}

type QueryResult

type QueryResult struct {
	TotalHits       int
	Size            int
	From            int
	Items           []*item.Item
	ItemIDs         []string
	Scores          []float64
	CategoryFacets  []*CategoryFacet
	AttributeFacets []*AttributeFacet
}

func Query

func Query(a QueryArgs) (*QueryResult, error)

type SearchResult

type SearchResult struct {
	Took int64 `json:"took"` // 2

	Hits struct {
		Total struct {
			Value    int64  `json:"value"`
			Relation string `json:"relation"`
		} `json:"total"`
		Hits []struct {
			Index  string     `json:"_index"` // "test"
			ID     string     `json:"_id"`    // "102"
			Score  float64    `json:"_score"` // 10.781843
			Source *item.Item `json:"_source"`
		} `json:"hits"`
	} `json:"hits"`

	Aggs map[string]*Aggs `json:"aggregations"`
}

Jump to

Keyboard shortcuts

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