Documentation
¶
Index ¶
- Constants
- Variables
- func CloseWith(closer io.Closer)
- func Convert(pa string, delta time.Duration, create func(pa string) (Writer, error)) error
- func DeleteIndex(i *Index) error
- func ErrArray(errList []error) error
- func GroupBy(seacher Searcher, ctx context.Context, startAt, endAt time.Time, q query.Query, ...) error
- func GroupByNumeric(seacher Searcher, ctx context.Context, startAt, endAt time.Time, q query.Query, ...) error
- func GroupByTime(seacher Searcher, ctx context.Context, startAt, endAt time.Time, q query.Query, ...) error
- func MultiSearch(ctx context.Context, req *bleve.SearchRequest, indexes []*LazyIndex) (*bleve.SearchResult, error)
- func ParseTime(s string) time.Time
- func SearchString(ctx context.Context, logger *log.Logger, searcher Searcher, q string) (<-chan string, error)
- func SetSegoRootDir(dir string)
- type Batcher
- type Continuation
- type DocID
- type DocIDs
- type Document
- type Engine
- func (e *Engine) Close() error
- func (e *Engine) FieldDict(ctx context.Context, startTime, endTime time.Time, field string) ([]bleve_index.DictEntry, error)
- func (e *Engine) Fields(ctx context.Context, startTime, endTime time.Time) ([]string, error)
- func (e *Engine) Index(ctx *Continuation, events []Document) error
- func (e *Engine) Open() error
- func (e *Engine) Path() string
- func (e *Engine) Query(ctx context.Context, startTime, endTime time.Time, req *bleve.SearchRequest, ...) error
- func (e *Engine) Total() (uint64, error)
- type EventIndexer
- type Index
- func (i *Index) Close() error
- func (i *Index) Contains(t time.Time) bool
- func (i *Index) Document(id DocID) ([]byte, error)
- func (i *Index) EndTime() time.Time
- func (i *Index) Expired(t time.Time, r time.Duration) bool
- func (i *Index) Index(documents []Document) error
- func (i *Index) Path() string
- func (i *Index) Search(q string) (DocIDs, error)
- func (i *Index) Shard(docId DocID) *Shard
- func (i *Index) StartTime() time.Time
- func (i *Index) Total() (uint64, error)
- type IndexLoader
- func (loader *IndexLoader) Close() error
- func (loader *IndexLoader) Do(cb func(loader *IndexLoader, switchFunc func()))
- func (loader *IndexLoader) GetIndexes(startTime, endTime time.Time) []*LazyIndex
- func (loader *IndexLoader) Load(ctx context.Context, li *LazyIndex) (*ResourceIndex, error)
- func (il *IndexLoader) Open(pa string, numShards, numCaches int, indexDuration time.Duration) error
- type Indexes
- type LazyIndex
- type LazyIndexes
- type ResourceIndex
- type Searcher
- type Shard
- type Writer
Constants ¶
const ( DefaultNumShards = 4 DefaultIndexDuration = 24 * time.Hour DefaultRetentionPeriod = 7 * 24 * time.Hour RetentionCheckInterval = time.Hour )
Engine defaults
const ( // MaxSearchHitSize the max search record in results MaxSearchHitSize = 10000 SegoDictPath = "lib/sego_dictionary.txt" )
Variables ¶
var ErrNotFound = errors.New("not found")
Functions ¶
func GroupByNumeric ¶ added in v1.3.2
func GroupByTime ¶ added in v1.3.1
func MultiSearch ¶ added in v1.3.1
func MultiSearch(ctx context.Context, req *bleve.SearchRequest, indexes []*LazyIndex) (*bleve.SearchResult, error)
MultiSearch executes a SearchRequest across multiple Index objects, then merges the results. The indexes must honor any ctx deadline.
func SearchString ¶ added in v1.3.1
func SetSegoRootDir ¶ added in v1.3.3
func SetSegoRootDir(dir string)
Types ¶
type Batcher ¶
type Batcher struct {
// contains filtered or unexported fields
}
Batcher accepts "input events", and once it has a certain number, or a certain amount of time has passed, sends those as indexable Events to an Indexer. It also supports a maximum number of unprocessed Events it will keep pending. Once this limit is reached, it will not accept anymore until outstanding Events are processed.
func NewBatcher ¶
NewBatcher returns a Batcher for EventIndexer e, a batching size of sz, a maximum duration of dur, and a maximum outstanding count of max.
type Continuation ¶ added in v1.3.1
type Continuation struct {
// contains filtered or unexported fields
}
func (*Continuation) Close ¶ added in v1.3.1
func (c *Continuation) Close() error
type DocID ¶
type DocID string
DocID is a string, with the following configuration. It's 32-characters long, encoding 2 64-bit unsigned integers. When sorting DocIDs, the first 16 characters, reading from the left hand side represent the most significant 64-bit number. And therefore the next 16 characters represent the least-significant 64-bit number.
type Engine ¶
type Engine struct { NumShards int // Number of shards to use when creating an index. NumCaches int // Number of caches to use when search in index. IndexDuration time.Duration // Duration of created indexes. RetentionPeriod time.Duration // How long after Index end-time to hang onto data. Logger *log.Logger // contains filtered or unexported fields }
Engine is the component that performs all indexing.
func (*Engine) Index ¶
func (e *Engine) Index(ctx *Continuation, events []Document) error
Index indexes a batch of Events. It blocks until all processing has completed.
func (*Engine) Query ¶ added in v1.3.1
func (e *Engine) Query(ctx context.Context, startTime, endTime time.Time, req *bleve.SearchRequest, cb func(*bleve.SearchRequest, *bleve.SearchResult) error) error
type EventIndexer ¶
type EventIndexer interface {
Index(ctx *Continuation, events []Document) error
}
EventIndexer is the interface a system than can index events must implement.
type Index ¶
type Index struct { Shards []*Shard // Individual bleve indexes Alias bleve.IndexAlias // All bleve indexes as one reference, for search // contains filtered or unexported fields }
Index represents a collection of shards. It contains data for a specific time range.
func NewIndex ¶
NewIndex returns an Index for the given start and end time, with the requested shards. It returns an error if an index already exists at the path.
func (*Index) Contains ¶
Contains returns whether the index's time range includes the given reference time.
func (*Index) Expired ¶
Expired returns whether the index has expired at the given time, if the retention period is r.
func (*Index) Index ¶
Index indexes the slice of documents in the index. It takes care of all shard routing.
func (*Index) Search ¶
Search performs a search of the index using the given query. Returns IDs of documents which satisfy all queries. Returns Doc IDs in sorted order, ascending.
type IndexLoader ¶ added in v1.3.1
type IndexLoader struct {
// contains filtered or unexported fields
}
func (*IndexLoader) Close ¶ added in v1.3.1
func (loader *IndexLoader) Close() error
func (*IndexLoader) Do ¶ added in v1.3.1
func (loader *IndexLoader) Do(cb func(loader *IndexLoader, switchFunc func()))
func (*IndexLoader) GetIndexes ¶ added in v1.3.1
func (loader *IndexLoader) GetIndexes(startTime, endTime time.Time) []*LazyIndex
func (*IndexLoader) Load ¶ added in v1.3.1
func (loader *IndexLoader) Load(ctx context.Context, li *LazyIndex) (*ResourceIndex, error)
type Indexes ¶
type Indexes []*Index
Indexes is a slice of indexes.
type LazyIndex ¶ added in v1.3.1
type LazyIndex struct {
// contains filtered or unexported fields
}
func OpenLazyIndex ¶ added in v1.3.1
OpenLazyIndex opens an existing index, at the given path.
func (*LazyIndex) Contains ¶ added in v1.3.1
Contains returns whether the index's time range includes the given reference time.
func (*LazyIndex) Expired ¶ added in v1.3.1
Expired returns whether the index has expired at the given time, if the retention period is r.
func (*LazyIndex) Load ¶ added in v1.3.1
func (i *LazyIndex) Load(ctx context.Context) (*ResourceIndex, error)
type LazyIndexes ¶ added in v1.3.1
type LazyIndexes []*LazyIndex
Indexes is a slice of indexes.
func (LazyIndexes) Len ¶ added in v1.3.1
func (i LazyIndexes) Len() int
Indexes are ordered by decreasing end time. If two indexes have the same end time, then order by decreasing start time. This means that the first index in the slice covers the latest time range.
func (LazyIndexes) Less ¶ added in v1.3.1
func (i LazyIndexes) Less(u, v int) bool
func (LazyIndexes) Swap ¶ added in v1.3.1
func (i LazyIndexes) Swap(u, v int)
type ResourceIndex ¶ added in v1.3.1
type ResourceIndex struct { *Index // contains filtered or unexported fields }
func (*ResourceIndex) Close ¶ added in v1.3.1
func (ri *ResourceIndex) Close() error
type Searcher ¶
type Searcher interface { Query(ctx context.Context, startTime, endTime time.Time, req *bleve.SearchRequest, cb func(*bleve.SearchRequest, *bleve.SearchResult) error) error Fields(ctx context.Context, startTime, endTime time.Time) ([]string, error) FieldDict(ctx context.Context, startTime, endTime time.Time, field string) ([]bleve_index.DictEntry, error) }
Searcher is the interface any object that perform searches should implement.
type Shard ¶
type Shard struct {
// contains filtered or unexported fields
}
Shard is a the basic data store for indexed data. Indexing operations are not goroutine safe, and only 1 indexing operation should occur at one time.
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
cmd
|
|
Package query implements a parser for the Ekanite query language.
|
Package query implements a parser for the Ekanite query language. |
Package rfc5424 is a state-machine parser of RFC5424-formatted log lines.
|
Package rfc5424 is a state-machine parser of RFC5424-formatted log lines. |