elastic

package
v0.0.0-...-2c27dae Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2022 License: Apache-2.0 Imports: 14 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connector

type Connector[T any] struct {
	abstract.ConfigurableConnector
	Client    *es.Client
	IndexName string
}

Connector ... Connector type

func NewElasticConnector

func NewElasticConnector[T any]() *Connector[T]

NewElasticConnector factory

func (*Connector[T]) CheckIndex

func (c *Connector[T]) CheckIndex(def *conf.DataSourceDefinition) error

func (*Connector[T]) CloseConnection

func (c *Connector[T]) CloseConnection()

func (*Connector[T]) Delete

func (c *Connector[T]) Delete(id string) error

func (*Connector[T]) DeleteByQuery

func (c *Connector[T]) DeleteByQuery(body *bytes.Buffer) error

func (*Connector[T]) InitConnection

func (c *Connector[T]) InitConnection(def *conf.DataSourceDefinition)

InitConnection ... Starts a connection with Elastic Search

func (*Connector[T]) Search

func (c *Connector[T]) Search(buf *bytes.Buffer) (*SearchResponse[T], error)

func (*Connector[T]) SimilarToThis

func (c *Connector[T]) SimilarToThis(vectorFieldName string, vector []float32, k int, numCandidates int, projectionFields []string, filter *map[string]interface{}) (*SearchResponse[T], error)

type Hits

type Hits[T any] struct {
	Total    Total            `json:"total,omitempty"`
	MaxScore float64          `json:"max_score,omitempty"`
	Hits     []ResponseDoc[T] `json:"hits,omitempty"`
}

type ResponseDoc

type ResponseDoc[T any] struct {
	Index  string  `json:"_index,omitempty"`
	Type   string  `json:"_type,omitempty"`
	ID     string  `json:"_id,omitempty"`
	Score  float64 `json:"_score,omitempty"`
	Source T       `json:"_source,omitempty"`
}

type SearchResponse

type SearchResponse[T any] struct {
	Took     float64 `json:"took,omitempty"`
	TimedOut bool    `json:"timed_out,omitempty"`
	Shards   Shards  `json:"_shards,omitempty"`
	Hits     Hits[T] `json:"hits,omitempty"`
}

type Shards

type Shards struct {
	Total       float64 `json:"total,omitempty"`
	Successfull float64 `json:"successfull,omitempty"`
	Skipped     float64 `json:"skipped,omitempty"`
	Failed      float64 `json:"failed,omitempty"`
}

type Total

type Total struct {
	Value    float64 `json:"value,omitempty"`
	Relation string  `json:"relation,omitempty"`
}

Jump to

Keyboard shortcuts

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