searchstore

package
v0.0.0-...-eebd556 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: Apache-2.0 Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	SearchExecutionException       = "search_phase_execution_exception"
	TooManyBucketsException        = "too_many_buckets_exception"
	TooManyNestedClausesException  = "too_many_nested_clauses"
	TooManyClausesException        = "too_many_clauses"
	IllegalArgumentException       = "illegal_argument_exception"
	SnapshotInProgressException    = "snapshot_in_progress_exception"
	ResourceAlreadyExistsException = "resource_already_exists_exception"
)

Variables

View Source
var (
	ErrTooManyRequests            = errors.New("too many requests")
	ErrTooManyBuckets             = errors.New("too many buckets")
	ErrTooManyNestedClauses       = errors.New("too many nested clauses")
	ErrTooManyClauses             = errors.New("too many clauses")
	ErrUnsupportedSearchFieldType = errors.New("unsupported search field type")
	ErrResourceNotFound           = errors.New("search resource not found")
)

Functions

func CreateReader

func CreateReader(value any) (*bytes.Reader, error)

createReader returns a reader on the JSON representation of the given value.

func EncodeBulkItems

func EncodeBulkItems(buffer *bytes.Buffer, items []BulkItem) error

func IsErrResponse

func IsErrResponse(res apiResponse) error

func Ptr

func Ptr[T any](i T) *T

Types

type Aggregation

type Aggregation struct {
	Filter        *Condition             `json:"filter,omitempty"`
	Cardinality   *CardinalityAgg        `json:"cardinality,omitempty"`
	DateHistogram *DateHistogramAgg      `json:"date_histogram,omitempty"`
	Sum           *SumMinMaxAgg          `json:"sum,omitempty"`
	Min           *SumMinMaxAgg          `json:"min,omitempty"`
	Max           *SumMinMaxAgg          `json:"max,omitempty"`
	Avg           *SumMinMaxAgg          `json:"avg,omitempty"`
	Percentiles   *ESPercentilesAgg      `json:"percentiles,omitempty"`
	Terms         *TermsAgg              `json:"terms,omitempty"`
	Histogram     *HistogramAgg          `json:"histogram,omitempty"`
	Aggs          map[string]Aggregation `json:"aggs,omitempty"`
}

type BoolFilter

type BoolFilter struct {
	Filter             []Condition `json:"filter,omitempty"`
	Should             []Condition `json:"should,omitempty"`
	Must               []Condition `json:"must,omitempty"`
	MustNot            []Condition `json:"must_not,omitempty"`
	MinimumShouldMatch int         `json:"minimum_should_match,omitempty"`
}

type BulkIndex

type BulkIndex struct {
	Index       string `json:"_index"`
	ID          string `json:"_id"`
	Version     *int   `json:"version,omitempty"`
	VersionType string `json:"version_type,omitempty"`
}

type BulkItem

type BulkItem struct {
	Index  *BulkIndex      `json:"index,omitempty"`
	Delete *BulkIndex      `json:"delete,omitempty"`
	Doc    map[string]any  `json:"-"`
	Status int             `json:"-"`
	Error  json.RawMessage `json:"-"`
}

func VerifyResponse

func VerifyResponse(bodyBytes []byte, items []BulkItem) (failed []BulkItem, err error)

type BulkResponse

type BulkResponse struct {
	Errors bool `json:"errors"`
	Items  []BulkResponseItem
}

type BulkResponseItem

type BulkResponseItem struct {
	Index struct {
		Status int             `json:"status"`
		Error  json.RawMessage `json:"error"`
	} `json:"index"`
	Delete struct {
		Status int             `json:"status"`
		Error  json.RawMessage `json:"error"`
	} `json:"delete"`
}

type CardinalityAgg

type CardinalityAgg struct {
	Field              string `json:"field"`
	PrecisionThreshold int    `json:"precision_threshold"`
}

type CausedBy

type CausedBy struct {
	Type       string `mapstructure:"type"`
	Reason     string `mapstructure:"reason"`
	MaxBuckets int    `mapstructure:"max_buckets"`
}

type Client

type Client interface {
	CloseIndex(ctx context.Context, index string) error
	Count(ctx context.Context, index string) (int, error)
	CreateIndex(ctx context.Context, index string, body map[string]any) error
	DeleteByQuery(ctx context.Context, req *DeleteByQueryRequest) error
	DeleteIndex(ctx context.Context, index []string) error
	GetIndexAlias(ctx context.Context, name string) (map[string]any, error)
	GetIndexMappings(ctx context.Context, index string) (*Mappings, error)
	GetIndicesStats(ctx context.Context, indexPattern string) ([]IndexStats, error)
	Index(ctx context.Context, req *IndexRequest) error
	IndexWithID(ctx context.Context, req *IndexWithIDRequest) error
	IndexExists(ctx context.Context, index string) (bool, error)
	ListIndices(ctx context.Context, indices []string) ([]string, error)
	Perform(req *http.Request) (*http.Response, error)
	PutIndexAlias(ctx context.Context, index []string, name string) error
	PutIndexMappings(ctx context.Context, index string, body map[string]any) error
	PutIndexSettings(ctx context.Context, index string, body map[string]any) error
	RefreshIndex(ctx context.Context, index string) error
	Search(ctx context.Context, req *SearchRequest) (*SearchResponse, error)
	SendBulkRequest(ctx context.Context, items []BulkItem) ([]BulkItem, error)
	GetMapper() Mapper
}

type Condition

type Condition struct {
	Term       map[string]any `json:"term,omitempty"`
	Terms      map[string]any `json:"terms,omitempty"`
	Prefix     map[string]any `json:"prefix,omitempty"`
	Wildcard   map[string]any `json:"wildcard,omitempty"`
	IDs        map[string]any `json:"ids,omitempty"`
	Range      map[string]any `json:"range,omitempty"`
	Exists     *ExistsFilter  `json:"exists,omitempty"`
	Bool       *BoolFilter    `json:"bool,omitempty"`
	MultiMatch *MultiMatch    `json:"multi_match,omitempty"`
}

type CountResponse

type CountResponse struct {
	Count int `json:"count"`
}

type DateHistogramAgg

type DateHistogramAgg struct {
	Field            string  `json:"field"`
	FixedInterval    *string `json:"fixed_interval,omitempty"`
	CalendarInterval *string `json:"calendar_interval,omitempty"`
	TimeZone         *string `json:"time_zone,omitempty"`
	Format           string  `json:"format,omitempty"`
}

type DeleteByQueryRequest

type DeleteByQueryRequest struct {
	Index   []string
	Query   map[string]any
	Refresh bool
}

type ESPercentilesAgg

type ESPercentilesAgg struct {
	Field    string    `json:"field"`
	Percents []float32 `json:"percents"`
}

type ErrIllegalArgument

type ErrIllegalArgument struct {
	Reason string
}

func (*ErrIllegalArgument) Error

func (e *ErrIllegalArgument) Error() string

type ErrQueryInvalid

type ErrQueryInvalid struct {
	Cause error
}

func (ErrQueryInvalid) Error

func (e ErrQueryInvalid) Error() string

type ErrResourceAlreadyExists

type ErrResourceAlreadyExists struct {
	Reason string
}

func (ErrResourceAlreadyExists) Error

func (e ErrResourceAlreadyExists) Error() string

type ExistsFilter

type ExistsFilter struct {
	Field string `json:"field"`
}

type ExpFunction

type ExpFunction struct {
	Origin *string `json:"origin,omitempty"`
	Scale  string  `json:"scale"`
	Decay  float64 `json:"decay"`
}

type Field

type Field struct {
	SearchType Type
	IsArray    bool
	Metadata   Metadata
}

type FieldValueFactor

type FieldValueFactor struct {
	Field    string  `json:"field"`
	Factor   float32 `json:"factor"`
	Modifier int     `json:"modifier"`
}

type Function

type Function struct {
	Filter           *Condition             `json:"filter,omitempty"`
	FieldValueFactor *FieldValueFactor      `json:"field_value_factor,omitempty"`
	Weight           *float64               `json:"weight,omitempty"`
	Exp              map[string]ExpFunction `json:"exp,omitempty"`
}

type FunctionScore

type FunctionScore struct {
	Query     *Query     `json:"query,omitempty"`
	ScoreMode string     `json:"score_mode,omitempty"`
	BoostMode string     `json:"boost_mode,omitempty"`
	Boost     float64    `json:"boost,omitempty"`
	Functions []Function `json:"functions,omitempty"`
}

type Highlight

type Highlight struct {
	Fields   map[string]any `json:"fields"`
	Encoder  string         `json:"encoder"`
	PreTags  []string       `json:"pre_tags,omitempty"`
	PostTags []string       `json:"post_tags,omitempty"`
}

type HistogramAgg

type HistogramAgg struct {
	Field    string   `json:"field"`
	Interval float64  `json:"interval"`
	Offset   *float64 `json:"offset,omitempty"`
}

type Hit

type Hit struct {
	ID        string         `json:"_id"`
	Index     string         `json:"_index"`
	Version   int            `json:"_version"`
	Source    map[string]any `json:"_source"`
	Score     float64        `json:"_score"`
	Highlight map[string]any `json:"highlight"`
}

type Hits

type Hits struct {
	Total struct {
		Value    int    `json:"value"`
		Relation string `json:"relation"`
	} `json:"total"`
	Hits []Hit `json:"hits"`
}

type IndexRequest

type IndexRequest struct {
	Index   string
	Body    []byte
	Refresh string
}

type IndexStats

type IndexStats struct {
	Index            string `json:"index,omitempty"`
	PrimarySizeBytes uint64 `json:"primary_size_bytes,omitempty"`
	TotalSizeBytes   uint64 `json:"total_size_bytes,omitempty"`
}

type IndexStatsResponse

type IndexStatsResponse struct {
	Indices map[string]struct {
		Primaries struct {
			Store struct {
				SizeInBytes int `json:"size_in_bytes"`
			} `json:"store"`
		} `json:"primaries"`
		Total struct {
			Store struct {
				SizeInBytes int `json:"size_in_bytes"`
			} `json:"store"`
		} `json:"total"`
	} `json:"indices"`
}

type IndexWithIDRequest

type IndexWithIDRequest struct {
	Index   string
	ID      string
	Body    []byte
	Refresh string
}

type KNNQuery

type KNNQuery struct {
	Vector []float32 `json:"vector"`
	K      int       `json:"k"`
}

type Mapper

type Mapper interface {
	GetDefaultIndexSettings() map[string]any
	FieldMapping(*Field) (map[string]any, error)
}

type MappingResponse

type MappingResponse map[string]struct {
	Mappings Mappings
}

type Mappings

type Mappings struct {
	Properties map[string]any
	Dynamic    string
}

type Metadata

type Metadata struct {
	VectorDimension int
}

type MultiMatch

type MultiMatch struct {
	Query         string   `json:"query"`
	Type          string   `json:"type"`
	Fuzziness     int      `json:"fuzziness,omitempty"`
	Fields        []string `json:"fields,omitempty"`
	Lenient       bool     `json:"lenient,omitempty"`
	MaxExpansions int      `json:"max_expansions,omitempty"`
}

type Query

type Query struct {
	Bool          *BoolFilter          `json:"bool,omitempty"`
	FunctionScore *FunctionScore       `json:"function_score,omitempty"`
	ScriptScore   *ScriptScore         `json:"script_score,omitempty"`
	KNN           *map[string]KNNQuery `json:"knn,omitempty"`
}

type QueryBody

type QueryBody struct {
	Query      *Query                  `json:"query,omitempty"`
	Sort       *Sort                   `json:"sort,omitempty"`
	Highlight  *Highlight              `json:"highlight,omitempty"`
	Aggs       *map[string]Aggregation `json:"aggs,omitempty"`
	Size       int                     `json:"size,omitempty"`
	PostFilter *Condition              `json:"post_filter,omitempty"`
}

type ResponseError

type ResponseError struct {
	Type         string           `mapstructure:"type"`
	Reason       string           `mapstructure:"reason"`
	FailedShards []map[string]any `mapstructure:"failed_shards"`
	CausedBy     *CausedBy        `mapstructure:"caused_by"`
	RootCause    []RootCause      `mapstructure:"root_cause"`
}

type RetryableError

type RetryableError struct {
	Cause error
}

func (RetryableError) Error

func (r RetryableError) Error() string

func (RetryableError) Unwrap

func (r RetryableError) Unwrap() error

type RootCause

type RootCause struct {
	Type   string `mapstructure:"type"`
	Reason string `mapstructure:"reason"`
}

type Script

type Script struct {
	Source string         `json:"source"`
	Lang   string         `json:"lang"`
	Params map[string]any `json:"params,omitempty"`
}

type ScriptScore

type ScriptScore struct {
	Query  json.RawMessage `json:"query,omitempty"`
	Script *Script         `json:"script,omitempty"`
}

type SearchRequest

type SearchRequest struct {
	Index          *string
	ReturnVersion  *bool
	Size           *int
	From           *int
	Sort           *string
	SourceIncludes *string
	Query          io.Reader
}

type SearchResponse

type SearchResponse struct {
	Hits         Hits           `json:"hits"`
	Aggregations map[string]any `json:"aggregations"`
}

type Sort

type Sort []map[string]any

type SumMinMaxAgg

type SumMinMaxAgg struct {
	Field string `json:"field"`
}

type TermsAgg

type TermsAgg struct {
	Field string `json:"field"`
	Size  int    `json:"size"`
}

type Type

type Type uint
const (
	IntegerType Type = iota
	FloatType
	BoolType
	StringType
	DateTimeTZType
	DateTimeType
	DateType
	TimeType
	JSONType
	TextType
	PGVectorType
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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