Documentation
¶
Index ¶
- func CloseIndex(ctx context.Context, name string) error
- func DeleteIndex(ctx context.Context, name string) error
- func GetIndexSettings(ctx context.Context, name string) (map[string]interface{}, error)
- func IndexExists(ctx context.Context, name string) (bool, error)
- func OpenIndex(ctx context.Context, name string) error
- func RefreshIndex(ctx context.Context, names ...string) error
- type ConflictStrategy
- type FieldInfo
- type FieldMapper
- type IndexInfo
- type IndexSettingsUpdater
- func (u *IndexSettingsUpdater) CustomSetting(key string, value interface{}) *IndexSettingsUpdater
- func (u *IndexSettingsUpdater) MaxResultWindow(size int) *IndexSettingsUpdater
- func (u *IndexSettingsUpdater) RefreshInterval(interval string) *IndexSettingsUpdater
- func (u *IndexSettingsUpdater) Replicas(n int) *IndexSettingsUpdater
- func (u *IndexSettingsUpdater) Update() error
- type IndexStats
- type MapperOption
- type MappingBuilder
- func (b *MappingBuilder) AddBooleanField(name string) *MappingBuilder
- func (b *MappingBuilder) AddDateField(name string, format string) *MappingBuilder
- func (b *MappingBuilder) AddDoubleField(name string) *MappingBuilder
- func (b *MappingBuilder) AddField(name string, fieldType string) *MappingBuilder
- func (b *MappingBuilder) AddFloatField(name string) *MappingBuilder
- func (b *MappingBuilder) AddIntegerField(name string) *MappingBuilder
- func (b *MappingBuilder) AddKNNVectorField(name string, dimension int, method *KNNMethod) *MappingBuilder
- func (b *MappingBuilder) AddKeywordField(name string) *MappingBuilder
- func (b *MappingBuilder) AddLongField(name string) *MappingBuilder
- func (b *MappingBuilder) AddNestedField(name string, properties map[string]MappingProperty) *MappingBuilder
- func (b *MappingBuilder) AddObjectField(name string, properties map[string]MappingProperty) *MappingBuilder
- func (b *MappingBuilder) AddProperty(name string, property MappingProperty) *MappingBuilder
- func (b *MappingBuilder) AddTextField(name string, analyzer string) *MappingBuilder
- func (b *MappingBuilder) Build() (map[string]interface{}, error)
- func (b *MappingBuilder) BuildWithErrors() (map[string]interface{}, []error)
- func (b *MappingBuilder) Ensure() error
- type MappingCache
- type MergedMapping
- type QueryType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CloseIndex ¶
CloseIndex closes an index
func DeleteIndex ¶
DeleteIndex deletes an index
func GetIndexSettings ¶
GetIndexSettings retrieves the settings of an index
func IndexExists ¶
IndexExists checks if an index exists
Types ¶
type ConflictStrategy ¶
type ConflictStrategy int
ConflictStrategy determines how to handle field type conflicts across indices
const ( // MostCommon uses the most common type across indices MostCommon ConflictStrategy = iota // MostPermissive uses the most permissive type (text > keyword, long > integer) MostPermissive // Strict returns error on any conflict Strict // MostRecent uses type from the most recent index (by name sort) MostRecent )
type FieldInfo ¶
type FieldInfo struct {
BaseField string // e.g., "type", "attributes.file"
Type string // e.g., "text", "keyword", "integer"
Fields map[string]string // sub-fields: {"keyword": "keyword", "raw": "keyword"}
AllowsMatch bool // true for text fields
AllowsTerm bool // true for keyword/numeric/date/ip
SourceIndices []string // indices where field exists
HasConflict bool // true if type differs across indices
ConflictTypes map[string][]string // type -> [indices with that type]
}
FieldInfo contains information about a field's type and characteristics
type FieldMapper ¶
type FieldMapper struct {
// contains filtered or unexported fields
}
FieldMapper manages mapping cache and field resolution
func NewFieldMapper ¶
func NewFieldMapper(opts ...MapperOption) *FieldMapper
NewFieldMapper creates a new FieldMapper with the given options
func (*FieldMapper) GetMergedMapping ¶
func (f *FieldMapper) GetMergedMapping(ctx context.Context, indexPattern string) (*MergedMapping, error)
GetMergedMapping fetches and merges mappings for all indices matching the pattern
func (*FieldMapper) Invalidate ¶
func (f *FieldMapper) Invalidate(pattern string)
Invalidate removes a pattern from the cache
type IndexInfo ¶
type IndexInfo struct {
Name string `json:"name"`
Settings map[string]interface{} `json:"settings"`
Mappings map[string]interface{} `json:"mappings"`
Aliases map[string]interface{} `json:"aliases"`
}
IndexInfo represents information about an index
type IndexSettingsUpdater ¶
type IndexSettingsUpdater struct {
// contains filtered or unexported fields
}
IndexSettingsUpdater provides a fluent API for updating index settings
func NewIndexSettingsUpdater ¶
func NewIndexSettingsUpdater(ctx context.Context, index string) *IndexSettingsUpdater
NewIndexSettingsUpdater creates a new settings updater
func (*IndexSettingsUpdater) CustomSetting ¶
func (u *IndexSettingsUpdater) CustomSetting(key string, value interface{}) *IndexSettingsUpdater
CustomSetting sets a custom setting
func (*IndexSettingsUpdater) MaxResultWindow ¶
func (u *IndexSettingsUpdater) MaxResultWindow(size int) *IndexSettingsUpdater
MaxResultWindow sets the maximum result window size
func (*IndexSettingsUpdater) RefreshInterval ¶
func (u *IndexSettingsUpdater) RefreshInterval(interval string) *IndexSettingsUpdater
RefreshInterval sets the refresh interval
func (*IndexSettingsUpdater) Replicas ¶
func (u *IndexSettingsUpdater) Replicas(n int) *IndexSettingsUpdater
Replicas sets the number of replicas
func (*IndexSettingsUpdater) Update ¶
func (u *IndexSettingsUpdater) Update() error
Update applies the settings changes using the low-level client
type IndexStats ¶
type IndexStats struct {
DocsCount int64 `json:"docs_count"`
DocsDeleted int64 `json:"docs_deleted"`
StoreSizeBytes int64 `json:"store_size_bytes"`
PrimaryShards int `json:"primary_shards"`
ReplicaShards int `json:"replica_shards"`
}
IndexStats represents index statistics
func GetIndexStats ¶
func GetIndexStats(ctx context.Context, name string) (*IndexStats, error)
GetIndexStats retrieves statistics for an index
type MapperOption ¶
type MapperOption func(*MappingCache)
MapperOption configures the FieldMapper
func WithCacheTTL ¶
func WithCacheTTL(ttl time.Duration) MapperOption
WithCacheTTL sets the cache TTL duration
func WithConflictStrategy ¶
func WithConflictStrategy(strategy ConflictStrategy) MapperOption
WithConflictStrategy sets how to handle field type conflicts
func WithMaxCacheSize ¶
func WithMaxCacheSize(size int) MapperOption
WithMaxCacheSize sets the maximum cache size
func WithStrictMode ¶
func WithStrictMode(strict bool) MapperOption
WithStrictMode enables strict mode (error on unknown fields)
type MappingBuilder ¶
type MappingBuilder struct {
// contains filtered or unexported fields
}
MappingBuilder provides a fluent API for adding fields to existing indices
func NewMappingBuilder ¶
func NewMappingBuilder(ctx context.Context, index string) *MappingBuilder
NewMappingBuilder creates a new mapping builder for the specified index
func (*MappingBuilder) AddBooleanField ¶
func (b *MappingBuilder) AddBooleanField(name string) *MappingBuilder
AddBooleanField adds a boolean field
func (*MappingBuilder) AddDateField ¶
func (b *MappingBuilder) AddDateField(name string, format string) *MappingBuilder
AddDateField adds a date field with optional format
func (*MappingBuilder) AddDoubleField ¶
func (b *MappingBuilder) AddDoubleField(name string) *MappingBuilder
AddDoubleField adds a double field
func (*MappingBuilder) AddField ¶
func (b *MappingBuilder) AddField(name string, fieldType string) *MappingBuilder
AddField adds a field with the specified type
func (*MappingBuilder) AddFloatField ¶
func (b *MappingBuilder) AddFloatField(name string) *MappingBuilder
AddFloatField adds a float field
func (*MappingBuilder) AddIntegerField ¶
func (b *MappingBuilder) AddIntegerField(name string) *MappingBuilder
AddIntegerField adds an integer field
func (*MappingBuilder) AddKNNVectorField ¶
func (b *MappingBuilder) AddKNNVectorField(name string, dimension int, method *KNNMethod) *MappingBuilder
AddKNNVectorField adds a k-NN vector field for similarity search
func (*MappingBuilder) AddKeywordField ¶
func (b *MappingBuilder) AddKeywordField(name string) *MappingBuilder
AddKeywordField adds a keyword field
func (*MappingBuilder) AddLongField ¶
func (b *MappingBuilder) AddLongField(name string) *MappingBuilder
AddLongField adds a long field
func (*MappingBuilder) AddNestedField ¶
func (b *MappingBuilder) AddNestedField(name string, properties map[string]MappingProperty) *MappingBuilder
AddNestedField adds a nested field with properties
func (*MappingBuilder) AddObjectField ¶
func (b *MappingBuilder) AddObjectField(name string, properties map[string]MappingProperty) *MappingBuilder
AddObjectField adds an object field with properties
func (*MappingBuilder) AddProperty ¶
func (b *MappingBuilder) AddProperty(name string, property MappingProperty) *MappingBuilder
AddProperty adds a custom property definition
func (*MappingBuilder) AddTextField ¶
func (b *MappingBuilder) AddTextField(name string, analyzer string) *MappingBuilder
AddTextField adds a text field with an optional analyzer
func (*MappingBuilder) Build ¶
func (b *MappingBuilder) Build() (map[string]interface{}, error)
Build returns the mapping update request body
func (*MappingBuilder) BuildWithErrors ¶
func (b *MappingBuilder) BuildWithErrors() (map[string]interface{}, []error)
BuildWithErrors returns the mapping and any accumulated errors
func (*MappingBuilder) Ensure ¶
func (b *MappingBuilder) Ensure() error
Ensure applies the mapping to the index (idempotent - adds new fields only)
type MappingCache ¶
type MappingCache struct {
// contains filtered or unexported fields
}
MappingCache caches merged mappings with LRU eviction
func (*MappingCache) GetOrFetch ¶
func (c *MappingCache) GetOrFetch(ctx context.Context, pattern string) (*MergedMapping, error)
GetOrFetch retrieves from cache or fetches and caches
func (*MappingCache) Invalidate ¶
func (c *MappingCache) Invalidate(pattern string)
Invalidate removes the pattern from cache
type MergedMapping ¶
type MergedMapping struct {
IndexPattern string
Indices []string
Fields map[string]FieldInfo
ConflictCount int
FetchedAt time.Time
}
MergedMapping holds merged field definitions from multiple indices
func (*MergedMapping) GetConflicts ¶
func (m *MergedMapping) GetConflicts() []FieldInfo
GetConflicts returns a list of fields with type conflicts
func (*MergedMapping) GetFieldInfo ¶
func (m *MergedMapping) GetFieldInfo(field string) (FieldInfo, bool)
GetFieldInfo retrieves field info from merged mapping
func (*MergedMapping) HasConflicts ¶
func (m *MergedMapping) HasConflicts() bool
HasConflicts returns true if any fields have type conflicts
func (*MergedMapping) ResolveFieldName ¶
func (m *MergedMapping) ResolveFieldName(field string, queryType QueryType) (string, error)
ResolveFieldName returns the correct field name for the given query type
type QueryType ¶
type QueryType int
QueryType represents the type of query being performed
const ( QueryTypeTerm QueryType = iota QueryTypeTerms QueryTypeMatch QueryTypeMatchPhrase QueryTypeRange QueryTypeSort QueryTypeAggregation QueryTypeExists QueryTypeWildcard QueryTypeFuzzy // Works like Match - needs text fields QueryTypeRegexp // Works on keyword/text, prefers keyword QueryTypeMatchPhrasePrefix // Works like Match - needs text fields QueryTypePrefix // Works on keyword fields )