es

package
v0.0.0-...-b425644 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2019 License: Apache-2.0 Imports: 15 Imported by: 3

Documentation

Index

Constants

View Source
const (
	OK  = '2'
	AND = "AND"
	OR  = "OR"
)
View Source
const (
	Asc  = "asc"
	Desc = "desc"
)

Variables

This section is empty.

Functions

func IterateIndex

func IterateIndex(addr, name string, funcs ...func(*openIndexOpt)) (chan json.RawMessage, error)

func OpenIndexFields

func OpenIndexFields(fields []string) func(*openIndexOpt)

func OpenIndexQuery

func OpenIndexQuery(query *Query) func(*openIndexOpt)

func OpenIndexScroll

func OpenIndexScroll(scroll string) func(*openIndexOpt)

timespan how long each request is valid (e.g. 1m)

func OpenIndexSize

func OpenIndexSize(size int) func(*openIndexOpt)

Types

type Analysis

type Analysis struct {
	Analyzer Analyzer `json:"analyzer"`
}

type Analyzer

type Analyzer struct {
	Default AnalyzerType `json:"default"`
}

type AnalyzerType

type AnalyzerType struct {
	Type      string `json:"type,omitempty"`
	Tokenizer string `json:"tokenizer,omitempty"`
}

type BatchIndexer

type BatchIndexer struct {
	Address string
	// contains filtered or unexported fields
}

func NewBatchIndexer

func NewBatchIndexer(addr string) *BatchIndexer

func (*BatchIndexer) Add

func (i *BatchIndexer) Add(d *Doc) error

func (*BatchIndexer) Close

func (i *BatchIndexer) Close() error

func (*BatchIndexer) Flush

func (i *BatchIndexer) Flush() error

type BulkIndexJob

type BulkIndexJob struct {
	Key    string
	Type   string
	Index  string
	Record interface{}
}

type Client

type Client struct {
	Address string
}

func (*Client) Stats

func (c *Client) Stats() (*Stats, error)

type DateHistogram

type DateHistogram struct {
	Field      string `json:"field,omitempty"`
	Interval   string `json:"interval,omitempty"`
	ValueField string `json:"value_field,omitempty"`
}

type DateHistogramFacet

type DateHistogramFacet struct {
	Type    string                     `json:"term,omitempty"`
	Entries []*DateHistogramFacetEntry `json:"entries,omitempty"`
}

func (*DateHistogramFacet) Load

func (dhf *DateHistogramFacet) Load(m map[string]interface{}) error

type DateHistogramFacetEntry

type DateHistogramFacetEntry struct {
	Time       int64 `json:"time,omitempty"`
	Count      int64 `json:"count,omitempty"`
	Min        float64
	Max        float64
	Total      int64
	TotalCount int64
	Mean       float64
}

type Doc

type Doc struct {
	Index  string      `json:"_index,omitempty"`
	Type   string      `json:"_type,omitempty"`
	Id     string      `json:"_id,omitempty"`
	Source interface{} `json:"-"`
}

func (*Doc) IndexAttributes

func (doc *Doc) IndexAttributes() map[string]string

type DynamicTemplate

type DynamicTemplate struct {
	Match            string                  `json:"match,omitempty"`
	MatchMappingType string                  `json:"match_mapping_type,omitempty"`
	Mapping          *DynamicTemplateMapping `json:"mapping,omitempty"`
}

type DynamicTemplateMapping

type DynamicTemplateMapping struct {
	Type   string `json:"type,omitempty"`
	Index  string `json:"index,omitempty"`
	Format string `json:"format,omitempty"`
}

type DynamicTemplates

type DynamicTemplates []map[string]DynamicTemplate

type Entries

type Entries []*Entry

type Entry

type Entry struct {
	TimestampMicros int64   `json:"time"`
	Count           int64   `json:"count"`
	Min             float64 `json:"min,omitempty"`
	Max             float64 `json:"max,omitempty"`
	Total           float64 `json:"total,omitempty"`
	TotalCount      int64   `json:"total_count,omitempty"`
	Mean            float64 `json:"mean,omitempty"`
}

func (*Entry) Timestamp

func (entry *Entry) Timestamp() int64

type Facet

type Facet struct {
	Type           string      `json:"_type,omitempty"`
	Missing        int         `json:"missing,omitempty"`
	Total          int         `json:"total,omitempty"`
	Other          int         `json:"other,omitempty"`
	Terms          *FacetTerms `json:"terms,omitempty"`
	*Entries       `json:"entries,omitempty"`
	*DateHistogram `json:"date_histogram,omitempty"`
	Statistical    *StatisticalFacet `json:"statistical,omitempty"`
}

type FacetResponseTerm

type FacetResponseTerm struct {
	Term  interface{}
	Count int64
}

type FacetResponseTerms

type FacetResponseTerms []*FacetResponseTerm

type FacetTerm

type FacetTerm struct {
	Term  interface{} `json:"term"`
	Count int         `json:"count"`
}

type FacetTerms

type FacetTerms struct {
	Field   string        `json:"field,omitempty"`
	Size    int           `json:"size,omitempty"`
	Exclude []interface{} `json:"exclude,omitempty"`
}

type Facets

type Facets map[string]*Facet

type Failure

type Failure struct {
	Index  string `json:"index"`
	Shard  int    `json:"shard"`
	Status int    `json:"status"`
	Reason string `json:"reason"`
}

type Filter

type Filter struct {
	Not    *Not              `json:"not,omitempty"`
	And    []*Filter         `json:"and,omitempty"`
	Term   *Term             `json:"term,omitempty"`
	Terms  *Terms            `json:"terms,omitempty"`
	Range  map[string]*Range `json:"range,omitempty"`
	Script *Script           `json:"script,omitempty"`
}

type Filtered

type Filtered struct {
	Filter *Filter `json:"filter"`
	Query  *Query  `json:"query"`
}

type Hit

type Hit struct {
	Index  string  `json:"_index"`
	Type   string  `json:"_type"`
	Id     string  `json:"_id"`
	Score  float64 `json:"_score"`
	Source Source  `json:"_source"`
}

type HitRaw

type HitRaw struct {
	Index  string          `json:"_index"`
	Type   string          `json:"_type"`
	Id     string          `json:"_id"`
	Score  float64         `json:"_score"`
	Source json.RawMessage `json:"_source"`
}

type Hits

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

type HitsRaw

type HitsRaw struct {
	Total    int       `json:"total"`
	MaxScore float64   `json:"max_score"`
	Hits     []*HitRaw `json:"hits"`
}

type HttpResponse

type HttpResponse struct {
	*http.Response
	Body []byte
}

type Index

type Index struct {
	Address string
	Index   string
	Type    string

	BatchSize int
	Debug     bool
	Logger    Logger
	// contains filtered or unexported fields
}

func (*Index) BaseUrl

func (index *Index) BaseUrl() string

func (*Index) CreateIndex

func (index *Index) CreateIndex(config IndexConfig) (rsp *HttpResponse, e error)

func (*Index) DeleteByQuery

func (index *Index) DeleteByQuery(query string) (b []byte, e error)

func (*Index) DeleteIndex

func (index *Index) DeleteIndex() error

func (*Index) EnqueueBulkIndex

func (index *Index) EnqueueBulkIndex(key string, record interface{}) (bool, error)

func (*Index) EnqueueDoc

func (index *Index) EnqueueDoc(doc *Doc) (indexed bool, e error)

func (*Index) GlobalMapping

func (index *Index) GlobalMapping() (m *Mapping, e error)

func (*Index) IndexDocs

func (index *Index) IndexDocs(docs []*Doc) error

func (*Index) IndexExists

func (index *Index) IndexExists() (exists bool, e error)

func (*Index) IndexUrl

func (index *Index) IndexUrl() string

func (*Index) Indexer

func (idx *Index) Indexer() *Indexer

func (*Index) LogDebug

func (index *Index) LogDebug(format string, i ...interface{})

func (*Index) LogInfo

func (index *Index) LogInfo(format string, i ...interface{})

func (*Index) Mapping

func (index *Index) Mapping() (i interface{}, e error)

func (*Index) Post

func (index *Index) Post(u string, i interface{}) (*HttpResponse, error)

func (*Index) PostObject

func (index *Index) PostObject(i interface{}) (*HttpResponse, error)

func (*Index) Put

func (index *Index) Put(u string, i interface{}) (*HttpResponse, error)

func (*Index) PutMapping

func (index *Index) PutMapping(mapping interface{}) (rsp *HttpResponse, e error)

func (*Index) PutObject

func (index *Index) PutObject(id string, i interface{}) (*HttpResponse, error)

func (*Index) Refresh

func (index *Index) Refresh() error

func (*Index) ResetBatch

func (index *Index) ResetBatch()

func (*Index) RunBatchIndex

func (index *Index) RunBatchIndex() error

func (*Index) Search

func (index *Index) Search(req interface{}) (*Response, error)

func (*Index) SearchRaw

func (index *Index) SearchRaw(req interface{}) (*ResponseRaw, error)

func (*Index) Stats

func (index *Index) Stats() (*Stats, error)

func (*Index) Status

func (index *Index) Status() (status *Status, e error)

func (*Index) TypeUrl

func (index *Index) TypeUrl() string

type IndexConfig

type IndexConfig struct {
	Index IndexIndexConfig `json:"index"`
}

func KeywordIndex

func KeywordIndex() IndexConfig

type IndexIndexConfig

type IndexIndexConfig struct {
	Analysis Analysis `json:"analysis"`
}

type IndexMapping

type IndexMapping struct {
	Properties *IndexMappingProperties
}

type IndexMappingProperties

type IndexMappingProperties map[string]IndexMappingProperty

type IndexMappingProperty

type IndexMappingProperty struct {
	Type   string `json:"type"`
	Format string `json:"format,omitempty"`
}

type IndexMappings

type IndexMappings map[string]*IndexMapping

type IndexTemplate

type IndexTemplate struct {
	Template string                 `json:"template,omitempty"`
	Settings *indexTemplateSettings `json:"settings,omitempty"`
}

type Indexer

type Indexer struct {
	Index *Index

	IndexEvery time.Duration // triggers a new index run after that duration, will be reset when BatchSize reached
	BatchSize  int           // triggers a new index run when the batch reaches that size

	Stats *IndexerStats
	// contains filtered or unexported fields
}

func (*Indexer) Close

func (indexer *Indexer) Close() error

func (*Indexer) Finish

func (indexer *Indexer) Finish() error

func (*Indexer) Start

func (indexer *Indexer) Start() chan *Doc

TODO change handling to e.g. Add command with implizit opening of channel to not expose the channel to the public

type IndexerStats

type IndexerStats struct {
	Runs        int64
	IndexedDocs int64
	TotalTime   time.Duration
	// contains filtered or unexported fields
}

func (*IndexerStats) Add

func (stats *IndexerStats) Add(count int, dur time.Duration)

func (*IndexerStats) String

func (i *IndexerStats) String() string

type Logger

type Logger interface {
	Debug(format string, i ...interface{})
	Info(format string, i ...interface{})
	Error(format string, i ...interface{})
}

type Mapping

type Mapping map[string]IndexMappings

func (Mapping) IndexNames

func (mapping Mapping) IndexNames() []string

type Not

type Not struct {
	Filter *Filter `json:"filter,omitempty"`
}

type Query

type Query struct {
	Filtered    *Filtered    `json:"filtered,omitempty"`
	QueryString *QueryString `json:"query_string,omitempty"`
}

type QueryString

type QueryString struct {
	Query           string `json:"query,omitempty"`
	DefaultOperator string `json:"default_operator,omitempty"`
}

type Range

type Range struct {
	GreaterThan        string `json:"gt,omitempty"`
	GreaterOrEqualThan string `json:"gte,omitempty"`
	LessThan           string `json:"lt,omitempty"`
	LessOrEqualThan    string `json:"lte,omitempty"`
}

type Request

type Request struct {
	Index        string      `json:"-"`
	Query        interface{} `json:"query,omitempty"`
	Size         int         `json:"size"`
	Facets       `json:"facets,omitempty"`
	Aggregations map[string]json.Marshaler `json:"aggs,omitempty"`
	*Sort        `json:"sort,omitempty"`
}

func (*Request) AddFacet

func (request *Request) AddFacet(key string, facet *Facet)

type RequestFacet

type RequestFacet struct {
	*Terms         `json:"terms,omitempty"`
	*DateHistogram `json:"date_histogram,omitempty"`
}

type Response

type Response struct {
	Took         int                       `json:"took"`
	TimedOut     bool                      `json:"timed_out"`
	Facets       ResponseFacets            `json:"facets"`
	Hits         Hits                      `json:"hits"`
	Shards       *ShardsResponse           `json:"_shards,omitempty"`
	Raw          []byte                    `json:"-"`
	Aggregations aggregations.Aggregations `json:"aggregations,omitempty"`
}

func NewResponse

func NewResponse(raw []byte) *Response

func (*Response) SetRaw

func (s *Response) SetRaw(b []byte)

func (*Response) ShardsResponse

func (r *Response) ShardsResponse() *ShardsResponse

type ResponseFacet

type ResponseFacet struct {
	Type    string       `json:"_type"`
	Missing int          `json:"missing"`
	Total   int          `json:"total"`
	Other   int          `json:"other"`
	Terms   []*FacetTerm `json:"terms,omitempty"`
	Entries []*Entry     `json:"entries,omitempty"`
}

type ResponseFacets

type ResponseFacets map[string]*ResponseFacet

type ResponseRaw

type ResponseRaw struct {
	*Response
	Hits *HitsRaw `json:"hits"`
}

type Script

type Script struct {
	Script string                 `json:"script,omitempty"`
	Params map[string]interface{} `json:"params,omitempty"`
}

type Sharder

type Sharder interface {
	ShardsResponse() *ShardsResponse
	SetRaw([]byte)
}

type Shards

type Shards struct {
	Total      int `json:"total"`
	Successful int `json:"successful"`
	Failed     int `json:"failed"`
}

type ShardsResponse

type ShardsResponse struct {
	Total      int        `json:"total"`
	Successful int        `json:"successful"`
	Failed     int        `json:"failed"`
	Failures   []*Failure `json:"failures"`
}

type Sort

type Sort map[string]*SortCriteria

type SortCriteria

type SortCriteria struct {
	Order string `json:"order,omitempty"`
}

type Source

type Source map[string]interface{}

func (*Source) Unmarshal

func (source *Source) Unmarshal(i interface{}) error

type StatisticalFacet

type StatisticalFacet struct {
	Type         string  `json:"_type,omitempty"`
	Count        int64   `json:"count,omitempty"`
	Total        int64   `json:"total,omitempty"`
	Min          float64 `json:"min,omitempty"`
	Max          float64 `json:"max,omitempty"`
	Mean         float64 `json:"mean,omitempty"`
	SumOfSquares float64 `json:"sum_of_squares,omitempty"`
	Variance     float64 `json:"variance,omitempty"`
	StdDeviation float64 `json:"std_deviation,omitempty"`
}

func (*StatisticalFacet) Load

func (sf *StatisticalFacet) Load(m map[string]interface{}) error

type Stats

type Stats struct {
	Shards  *Shards `json:"_shards,omitempty"`
	Indices map[string]*indexStats
}

func (*Stats) IndexNames

func (stats *Stats) IndexNames() []string

type Status

type Status struct {
	Ok     bool    `json:"ok"`
	Shards *Shards `json:"_shards"`
}

type Term

type Term map[string]interface{}

type Terms

type Terms map[string][]interface{}

type TermsFacet

type TermsFacet struct {
	Type    string             `json:"_type,omitempty"`
	Missing int64              `json:"missing,omitempty"`
	Total   int64              `json:"total,omitempty"`
	Other   int64              `json:"other,omitempty"`
	Terms   FacetResponseTerms `json:"terms,omitempty"`
}

func (*TermsFacet) Load

func (tf *TermsFacet) Load(m map[string]interface{}) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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