Documentation
¶
Index ¶
- Constants
- func ToAnySlice[T any](s []T) []any
- type AggBucket
- type BoolQuery
- type BulkOp
- type Indexer
- func (i *Indexer) Bulk(ctx context.Context, ops []BulkOp) error
- func (i *Indexer) Close()
- func (i *Indexer) Delete(ctx context.Context, id string) error
- func (i *Indexer) DeleteByQuery(ctx context.Context, query Query) error
- func (i *Indexer) Index(ctx context.Context, id string, doc any) error
- func (i *Indexer) Init(ctx context.Context) (bool, error)
- func (i *Indexer) Ping(ctx context.Context) error
- func (i *Indexer) Refresh(ctx context.Context) error
- func (i *Indexer) Search(ctx context.Context, req SearchRequest) (*SearchResponse, error)
- func (i *Indexer) VersionedIndexName() string
- type MultiMatchQuery
- type Query
- type RangeQuery
- type SearchHit
- type SearchRequest
- type SearchResponse
- type SortField
Constants ¶
const ( MultiMatchTypeBestFields = "best_fields" MultiMatchTypePhrasePrefix = "phrase_prefix" )
MultiMatch types used by the call sites. See https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html#multi-match-types
Variables ¶
This section is empty.
Functions ¶
func ToAnySlice ¶
ToAnySlice converts []T to []any for variadic query args like TermsQuery.
Types ¶
type BoolQuery ¶
type BoolQuery struct {
// contains filtered or unexported fields
}
BoolQuery is the fluent builder for a bool query.
func NewBoolQuery ¶
func NewBoolQuery() *BoolQuery
type BulkOp ¶
type BulkOp struct {
// contains filtered or unexported fields
}
BulkOp is a single write inside a Bulk call. Construct with IndexOp or DeleteOp.
type Indexer ¶
type Indexer struct {
// contains filtered or unexported fields
}
Indexer is a narrow wrapper around an Elasticsearch/OpenSearch cluster. It targets the REST subset shared by Elasticsearch 7/8/9 and OpenSearch 3.
func NewIndexer ¶
NewIndexer builds an Indexer. The connection is opened by Init.
func (*Indexer) Close ¶
func (i *Indexer) Close()
Close releases idle HTTP connections held by the client.
func (*Indexer) DeleteByQuery ¶
DeleteByQuery removes every document matching the query.
func (*Indexer) Init ¶
Init connects and creates the versioned index if missing, returning true if it already existed.
func (*Indexer) Search ¶
func (i *Indexer) Search(ctx context.Context, req SearchRequest) (*SearchResponse, error)
Search runs a search request and decodes the reply.
func (*Indexer) VersionedIndexName ¶
VersionedIndexName returns the full index name with version suffix.
type MultiMatchQuery ¶
type MultiMatchQuery struct {
// contains filtered or unexported fields
}
MultiMatchQuery is the fluent builder for a multi_match query.
func NewMultiMatchQuery ¶
func NewMultiMatchQuery(query any, fields ...string) *MultiMatchQuery
NewMultiMatchQuery creates a multi_match query over the given fields.
func (*MultiMatchQuery) Operator ¶
func (m *MultiMatchQuery) Operator(op string) *MultiMatchQuery
func (*MultiMatchQuery) Type ¶
func (m *MultiMatchQuery) Type(t string) *MultiMatchQuery
type Query ¶
type Query interface {
// contains filtered or unexported methods
}
Query is an Elasticsearch query DSL node. It marshals to the JSON object expected by the ES query API.
func MatchPhraseQuery ¶
MatchPhraseQuery matches the exact phrase on `field`.
func MatchQuery ¶
MatchQuery is a full-text match on a single field.
func TermsQuery ¶
TermsQuery matches documents whose `field` equals any of `values`.
type RangeQuery ¶
type RangeQuery struct {
// contains filtered or unexported fields
}
RangeQuery is the fluent builder for a range query.
func NewRangeQuery ¶
func NewRangeQuery(field string) *RangeQuery
func (*RangeQuery) Gte ¶
func (r *RangeQuery) Gte(v any) *RangeQuery
func (*RangeQuery) Lte ¶
func (r *RangeQuery) Lte(v any) *RangeQuery
type SearchRequest ¶
type SearchRequest struct {
Query Query
Sort []SortField
From int
Size int
TrackTotal bool
Aggregations map[string]any
Highlight map[string]any
}
SearchRequest captures everything Gitea sends to the _search endpoint. Aggregations and Highlight are raw ES JSON bodies — callers write them as map[string]any since each has exactly one call site with a fixed shape.
type SearchResponse ¶
SearchResponse is Gitea's decoded view of the search reply.