elastic

package
v0.0.0-...-d78745c Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsValidKey

func IsValidKey(str string, list []string) bool

IsValidKey checks if a string is in an array

func ParseDocument

func ParseDocument(source map[string]interface{}) (map[string]interface{}, error)

ParseDocument

func ParseDocuments

func ParseDocuments(res map[string]interface{}) (map[string]interface{}, error)

ParseDocuments

func ParserAggregation

func ParserAggregation(res map[string]interface{}) (map[string]interface{}, error)

ParserAggregation

func RemoveKey

func RemoveKey(s []string, index int) []string

RemoveKey removes an invalid key from keys

Types

type BoolQuery

type BoolQuery struct {
	Bool          *BoolQueryParams `json:"bool,omitempty"`
	FunctionScore interface{}      `json:"function_score,omitempty"`
}

BoolQuery Struct

type BoolQueryParams

type BoolQueryParams struct {
	MustNot            []map[string]interface{} `json:"must_not,omitempty"`
	Must               []map[string]interface{} `json:"must,omitempty"`
	Should             []map[string]interface{} `json:"should,omitempty"`
	Filter             []map[string]interface{} `json:"filter,omitempty"`
	MinimunShouldMatch interface{}              `json:"minimum_should_match,omitempty"`
}

BoolQueryParams Struct

type Elastic

type Elastic struct {
	Client *elasticsearch.Client
}

func NewElastic

func NewElastic(host, user, pass string) (*Elastic, error)

func (*Elastic) CheckIfIndexExists

func (elastic *Elastic) CheckIfIndexExists(name string) bool

func (*Elastic) CreateIndex

func (elastic *Elastic) CreateIndex(name, template string)

type Query

type Query struct {
	Query        BoolQuery                `json:"query,omitempty"`
	Aggregations interface{}              `json:"aggs,omitempty"`
	Fields       []string                 `json:"fields,omitempty"`
	Source       []string                 `json:"_source,omitempty"`
	Sort         []map[string]interface{} `json:"sort,omitempty"`
	Size         int                      `json:"size" default:"0"`
	From         int                      `json:"from,omitempty"`
	SearchAfter  []int                    `json:"search_after,omitempty"`
}

Query Struct

func NewQuery

func NewQuery() *Query

NewQuery return a new query

func (*Query) Validate

func (q *Query) Validate()

Validate query fields

Jump to

Keyboard shortcuts

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