Documentation ¶
Index ¶
- type BulkAction
- type BulkActionDetail
- type BulkActionResult
- type BulkResult
- type BulkResultItem
- type BulkShards
- type DateRangeFacet
- type DateTimeRange
- type Document
- type DocumentMapping
- type Engine
- type FacetRequest
- type FacetResult
- type FieldMapping
- type Hit
- type Hits
- type Index
- func (index *Index) BulkIndex(docs []map[string]interface{}) error
- func (index *Index) Clone(name string) error
- func (index *Index) Close() error
- func (index *Index) Delete() error
- func (index *Index) DeleteDocument(docID string) error
- func (index *Index) GetDocument(docID string) (*Document, error)
- func (index *Index) IndexOrUpdateDocument(docID string, source map[string]interface{}) error
- func (index *Index) Open() error
- func (index *Index) Search(req *SearchRequest) (*SearchResult, error)
- func (index *Index) SetMapping(mapping interface{}) error
- func (index *Index) UpdateDocumentPartially(docID string, fields map[string]interface{}) error
- func (index *Index) UpdateMetadata() error
- func (index *Index) UpdateMetadataByShard(n int)
- type IndexMapping
- type IndexShard
- type NumericRange
- type NumericRangeFacet
- type Option
- type QueryStringQuery
- type SearchRequest
- type SearchResult
- type Status
- type TermFacet
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BulkAction ¶
type BulkAction struct { Index *BulkActionDetail `json:"index,omitempty"` Create *BulkActionDetail `json:"create,omitempty"` Update *BulkActionDetail `json:"update,omitempty"` Delete *BulkActionDetail `json:"delete,omitempty"` }
type BulkActionDetail ¶
type BulkActionResult ¶
type BulkActionResult struct { Index string `json:"_index"` ID string `json:"_id"` Version int64 `json:"_version"` Result string `json:"result,omitempty"` // 'created', 'deleted', 'indexed', 'updated' Shards *BulkShards `json:"_shards"` Status int64 `json:"status"` // 200 => indexed, updated, deleted 201 => created 404 => doc not found Error interface{} `json:"error,omitempty"` SeqNo int64 `json:"_seq_no"` PrimaryTerm int64 `json:"_primary_term"` }
func NewBulkActionResult ¶
type BulkResult ¶
type BulkResult struct { Took time.Duration `json:"took"` Errors bool `json:"errors,omitempty"` Items []BulkResultItem `json:"items"` }
func Bulk ¶
func Bulk(targetIndex string, reader io.Reader) (*BulkResult, error)
Bulk reads data from reader and execute bulk actions defined in reader. The first line looks like {"$action":{"_index": "$index", "_id": "$docID"}}, the $action can be `create`, `delete`, `index`, `update`. Note that here's update don't support update document partially because of performance. If $index is empty, the targetIndex will be used.
type BulkResultItem ¶
type BulkResultItem struct { Index *BulkActionResult `json:"index,omitempty"` Delete *BulkActionResult `json:"delete,omitempty"` Create *BulkActionResult `json:"create,omitempty"` Update *BulkActionResult `json:"update,omitempty"` }
type BulkShards ¶
type DateRangeFacet ¶
type DateTimeRange ¶
type DocumentMapping ¶
type DocumentMapping struct { Disabled bool `json:"disabled" mapstructure:"disabled"` Properties map[string]*DocumentMapping `json:"properties,omitempty" mapstructure:"properties"` Fields []*FieldMapping `json:"fields,omitempty" mapstructure:"fields"` DefaultAnalyzer string `json:"default_analyzer,omitempty" mapstructure:"default_analyzer"` }
type FacetRequest ¶
type FacetRequest struct { Size int `json:"size"` Field string `json:"field"` NumericRanges []NumericRange `json:"numeric_ranges,omitempty"` DateTimeRanges []DateTimeRange `json:"date_ranges,omitempty"` }
type FacetResult ¶
type FacetResult struct { Field string `json:"field"` Total int `json:"total"` Missing int `json:"missing"` Other int `json:"other"` DateRanges []DateRangeFacet `json:"date_ranges,omitempty"` NumericRanges []NumericRangeFacet `json:"numeric_ranges,omitempty"` Terms []TermFacet `json:"terms,omitempty"` }
type FieldMapping ¶
type FieldMapping struct { Type string `json:"type,omitempty" mapstructure:"type"` // support "keyword", "text", "datetime", "number", "boolean", "geopoint", "IP" Analyzer *string `json:"analyzer,omitempty" mapstructure:"analyzer"` // Analyzer specifies the name of the analyzer to use for this field. Store *bool `json:"store,omitempty" mapstructure:"store"` // Store indicates whether to store field values in the index. Index *bool `json:"index,omitempty" mapstructure:"index"` // Store indicates whether to analyze the field. }
type Hit ¶
type Hit struct { Index string `json:"_index"` ID string `json:"_id"` Score float64 `json:"_score"` Sort []string `json:"_sort"` Timestamp string `json:"@timestamp"` Explanation *search.Explanation `json:"_explanation,omitempty"` Locations search.FieldTermLocationMap `json:"_locations,omitempty"` Fragments search.FieldFragmentMap `json:"_fragments,omitempty"` Source map[string]interface{} `json:"_source,omitempty"` Fields map[string]interface{} `json:"_fields,omitempty"` }
type Index ¶
type Index struct { UID string `json:"uid"` Name string `json:"name"` Mapping *IndexMapping `json:"mapping"` DocNum uint64 `json:"doc_num"` // number of docs StorageSize uint64 `json:"storage_size"` // bytes on disk NumberOfShards int `json:"number_of_shards"` // number of shards Shards []*IndexShard `json:"shards"` CreateAt time.Time `json:"create_at"` UpdateAt time.Time `json:"update_at"` // contains filtered or unexported fields }
func GetIndex ¶
GetIndex firstly search in mem, than find in db, in err == nil and index != nil, it's ready to use(opened).
func ListIndices ¶
ListIndices list all managed indices, note: not opened!
func (*Index) Close ¶
Close closes index and release the related resource, including remove from engine.indices.
func (*Index) Delete ¶
Delete close the index, remove from engine.indices, delete all index files, delete index metadata.
func (*Index) DeleteDocument ¶
DeleteDocument try to delete the document from index, do not check if it exists.
func (*Index) GetDocument ¶
GetDocument returns the doc associated with docID.
func (*Index) IndexOrUpdateDocument ¶
IndexOrUpdateDocument indexes or update a document refers to `index`.
func (*Index) Search ¶
func (index *Index) Search(req *SearchRequest) (*SearchResult, error)
Search performs search in specified index.
func (*Index) SetMapping ¶
func (*Index) UpdateDocumentPartially ¶
UpdateDocumentPartially can update part fields of indexed document.
func (*Index) UpdateMetadata ¶
UpdateMetadata writes the index metadata to db.
func (*Index) UpdateMetadataByShard ¶
type IndexMapping ¶
type IndexMapping struct { TypeMapping map[string]*DocumentMapping `json:"types,omitempty" mapstructure:"types"` DefaultMapping *DocumentMapping `json:"default_mapping" mapstructure:"default_mapping"` TypeField *string `json:"type_field" mapstructure:"type_field"` DefaultType *string `json:"default_type" mapstructure:"default_type"` DefaultAnalyzer *string `json:"default_analyzer" mapstructure:"default_analyzer"` // standard, gse, sego ... }
func BuildIndexMappingFromMap ¶
func BuildIndexMappingFromMap(m map[string]interface{}) (*IndexMapping, error)
type IndexShard ¶
type NumericRange ¶
type NumericRangeFacet ¶
type Option ¶
type Option func(*options)
func WithIndexMapping ¶
func WithIndexMapping(m *IndexMapping) Option
func WithShards ¶
type QueryStringQuery ¶
func (*QueryStringQuery) Searcher ¶
func (q *QueryStringQuery) Searcher(i bindex.IndexReader, m imapping.IndexMapping, options search.SearcherOptions) (search.Searcher, error)
type SearchRequest ¶
type SearchRequest struct { Query query.Query `json:"query"` Size int `json:"size"` From int `json:"from"` Highlight []string `json:"highlight"` Fields []string `json:"fields"` Facets map[string]*FacetRequest `json:"facets"` Explain bool `json:"explain"` Sort []string `json:"sort"` IncludeLocations bool `json:"includeLocations"` SearchAfter []string `json:"search_after"` SearchBefore []string `json:"search_before"` }
func (*SearchRequest) UnmarshalJSON ¶
func (r *SearchRequest) UnmarshalJSON(input []byte) error
type SearchResult ¶
type SearchResult struct { Status Status `json:"status"` Request *SearchRequest `json:"request"` Hits Hits `json:"hits"` TotalHits uint64 `json:"total_hits"` MaxScore float64 `json:"max_score"` Took time.Duration `json:"took"` Facets map[string]*FacetResult `json:"facets,omitempty"` }
func Search ¶
func Search(req *SearchRequest) (*SearchResult, error)
Search performs search in all existing indices.