indexlib

package
v0.0.0-...-04d6450 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package indexlib organizes codes of the indexing library

Index

Constants

This section is empty.

Variables

View Source
var FieldTypes map[string]LibFieldType

FieldTypes maps from the mapping type to the index library type it belongs to.

Functions

func DeduceType

func DeduceType(value any) (string, bool)

DeduceType deduced Tatris field type from the value reference from: https://www.elastic.co/guide/en/elasticsearch/reference/8.6/dynamic-field-mapping.html

func ValidateValue

func ValidateValue(mType string, value any) bool

Types

type AggDateHistogram

type AggDateHistogram struct {
	Field            string
	FixedInterval    int64 // nanos
	CalendarInterval string
	Format           string
	TimeZone         *time.Location
	Offset           any
	MinDocCount      int
	Keyed            bool
	Missing          string
	ExtendedBounds   *DateHistogramBound
	HardBounds       *DateHistogramBound
}

type AggDateRange

type AggDateRange struct {
	Field    string
	Format   string
	TimeZone *time.Location
	Ranges   []DateRange
	Keyed    bool
}

type AggFilter

type AggFilter struct {
	FilterQuery QueryRequest
}

type AggHistogram

type AggHistogram struct {
	Field          string
	Interval       float64
	MinDocCount    int
	Offset         float64
	Keyed          bool
	Missing        string
	ExtendedBounds *HistogramBound
	HardBounds     *HistogramBound
}

type AggMetric

type AggMetric struct {
	Field string
}

type AggNumericRange

type AggNumericRange struct {
	Field  string
	Ranges []NumericRange
	Keyed  bool
}

type AggPercentiles

type AggPercentiles struct {
	Field       string
	Percents    []float64
	Compression float64
}

type AggTerms

type AggTerms struct {
	Field     string
	Size      int
	ShardSize int
}

type AggWeightedAvg

type AggWeightedAvg struct {
	Value  *AggMetric
	Weight *AggMetric
}

type Aggregation

type Aggregation struct {
	Value   interface{}       `json:"value,omitempty"`   // metric aggregation
	Buckets []protocol.Bucket `json:"buckets,omitempty"` // bucket aggregation
}

type Aggs

type Aggs struct {
	Terms         *AggTerms
	NumericRange  *AggNumericRange
	DateRange     *AggDateRange
	Count         *AggMetric
	Sum           *AggMetric
	Min           *AggMetric
	Max           *AggMetric
	Avg           *AggMetric
	Cardinality   *AggMetric
	WeightedAvg   *AggWeightedAvg
	Percentiles   *AggPercentiles
	DateHistogram *AggDateHistogram
	Histogram     *AggHistogram
	Filter        *AggFilter
	Aggs          map[string]Aggs
}

type BaseQuery

type BaseQuery struct {
	Boost float64
	Aggs  map[string]Aggs
	Sort  Sort
}

func NewBaseQuery

func NewBaseQuery() *BaseQuery

func (*BaseQuery) GetAggs

func (m *BaseQuery) GetAggs() map[string]Aggs

func (*BaseQuery) GetSort

func (m *BaseQuery) GetSort() Sort

func (*BaseQuery) SetAggs

func (m *BaseQuery) SetAggs(aggs map[string]Aggs)

func (*BaseQuery) SetSort

func (m *BaseQuery) SetSort(sort Sort)

type BooleanQuery

type BooleanQuery struct {
	*BaseQuery
	Musts     []QueryRequest
	Shoulds   []QueryRequest
	MustNots  []QueryRequest
	Filters   []QueryRequest
	MinShould int
}

func NewBooleanQuery

func NewBooleanQuery() *BooleanQuery

type Config

type Config struct {
	IndexLib      string
	DirectoryType string
	FS            *FileSystem
	OSS           *ObjectStorageService
}

func BuildConf

func BuildConf(directory *config.Directory) *Config

type DateHistogramBound

type DateHistogramBound struct {
	Min int64
	Max int64
}

type DateRange

type DateRange struct {
	To   string
	From string
}

type FileSystem

type FileSystem struct {
	Path string
}

type HistogramBound

type HistogramBound struct {
	Min float64
	Max float64
}

type Hit

type Hit struct {
	Index     string            `json:"_index"`
	ID        string            `json:"_id"`
	Source    protocol.Document `json:"_source"`
	Timestamp time.Time         `json:"@timestamp"`
	Score     float64           `json:"_score"`
	Type      string            `json:"_type"`
}

type Hits

type Hits struct {
	Total    Total   `json:"total"`
	Hits     []Hit   `json:"hits"`
	MaxScore float64 `json:"max_score"`
}

type HookReader

type HookReader struct {
	Reader
	CloseHook func(Reader)
}

HookReader wraps another Reader and uses hooks to intercept Reader's funcs. It only supports intercepting the 'Close' func at the present time.

func (*HookReader) Close

func (r *HookReader) Close()

type LibFieldType

type LibFieldType struct {
	Type         string               // lib type
	MappingTypes []string             // Tatris mapping types
	Validator    func(value any) bool // used to validate whether the value matches the field type
}

LibFieldType defines the field types supported by Tatris based on the underlying index library.

func ValidateMappingType

func ValidateMappingType(mType string) (bool, LibFieldType)

type MatchAllQuery

type MatchAllQuery struct {
	*BaseQuery
}

func NewMatchAllQuery

func NewMatchAllQuery() *MatchAllQuery

type MatchPhraseQuery

type MatchPhraseQuery struct {
	*BaseQuery
	MatchPhrase string
	Field       string
	Analyzer    string
	Slop        int // Defaults to 0
}

func NewMatchPhraseQuery

func NewMatchPhraseQuery() *MatchPhraseQuery

type MatchQuery

type MatchQuery struct {
	*BaseQuery
	Match     string
	Field     string
	Analyzer  string // STANDARD(default), KEYWORD, SIMPLE, WEB
	Prefix    int    // Defaults to 0
	Fuzziness int
	Operator  string // OR, AND
}

func NewMatchQuery

func NewMatchQuery() *MatchQuery

type NumericRange

type NumericRange struct {
	To   float64
	From float64
}

type ObjectStorageService

type ObjectStorageService struct {
	Endpoint                   string
	Bucket                     string
	AccessKeyID                string
	SecretAccessKey            string
	MinimumConcurrencyLoadSize int
}

type QueryRequest

type QueryRequest interface {
	SetAggs(aggregations map[string]Aggs)
	GetAggs() map[string]Aggs
	SetSort(sort Sort)
	GetSort() Sort
}

type QueryResponse

type QueryResponse struct {
	Took         int64                  `json:"took"`
	Hits         Hits                   `json:"hits"`
	Aggregations map[string]Aggregation `json:"aggregations"`
}

type QueryString

type QueryString struct {
	*BaseQuery
	Query    string
	Analyzer string
}

func NewQueryString

func NewQueryString() *QueryString

type RangeQuery

type RangeQuery struct {
	*BaseQuery
	Range map[string]*RangeVal
}

func NewRangeQuery

func NewRangeQuery() *RangeQuery

type RangeVal

type RangeVal struct {
	GT  interface{}
	GTE interface{}
	LT  interface{}
	LTE interface{}
}

type Reader

type Reader interface {
	OpenReader() error
	Search(ctx context.Context, req QueryRequest, limit, from int) (*QueryResponse, error)
	Count() int
	Close()
}

func UnwrapReader

func UnwrapReader(r Reader) Reader

UnwrapReader unwraps a reader to the underlying reader if it wraps other reader.

type Sort

type Sort []map[string]SortTerm

type SortTerm

type SortTerm struct {
	Order   string
	Missing string
}

type TermQuery

type TermQuery struct {
	*BaseQuery
	Term  string
	Field string
}

func NewTermQuery

func NewTermQuery() *TermQuery

type Terms

type Terms struct {
	*BaseQuery
	Fields []string
}

func NewTerms

func NewTerms() *Terms

type TermsQuery

type TermsQuery struct {
	*BaseQuery
	Terms map[string]*Terms
}

func NewTermsQuery

func NewTermsQuery() *TermsQuery

type Total

type Total struct {
	Value    int64  `json:"value"`
	Relation string `json:"relation"`
}

type Writer

type Writer interface {
	OpenWriter() error
	Insert(docID string, doc protocol.Document) error
	Batch(docs map[string]protocol.Document) error
	Reader() (Reader, error)
	Close()
}

Directories

Path Synopsis
Package bluge organizes codes of the indexing library bluge
Package bluge organizes codes of the indexing library bluge
aggregations
Package aggregations contains custom aggregation for bluge
Package aggregations contains custom aggregation for bluge
config
Package config organizes codes of the bluge config
Package config organizes codes of the bluge config
directory/fs
Package fs is just a simple encapsulation of index.NewFileSystemDirectory for logging time cost.
Package fs is just a simple encapsulation of index.NewFileSystemDirectory for logging time cost.
directory/oss
Package oss is used to implement the AliCloud-Object-Storage-Service storage medium for the underlying data and indexes.
Package oss is used to implement the AliCloud-Object-Storage-Service storage medium for the underlying data and indexes.
Package manage organizes codes of the indexing library manage
Package manage organizes codes of the indexing library manage

Jump to

Keyboard shortcuts

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