Documentation ¶
Index ¶
- type Aggregations
- type Buckets
- type ESClient
- func (e *ESClient) CreateIndexDoc(index string, doc any, docid ...string) error
- func (e *ESClient) CreateIndexMapping(index, mapping string) error
- func (e *ESClient) IsExistIndex(index []string) bool
- func (e *ESClient) SearchIndex(index, query string, page int, limit ...int) (*Response, error)
- func (e *ESClient) UpdateIndexDoc(index, docid, doc string) error
- func (e *ESClient) UpdateIndexMapping(index []string, mapping string) error
- type ErrorResp
- type Reason
- type Response
- type RootCause
- type SearchHit
- type SearchHits
- type Shards
- type TopN
- type Total
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Aggregations ¶
type Aggregations struct {
TopN *TopN `json:"topN"`
}
type ESClient ¶
func CreateNewClient ¶
func (*ESClient) CreateIndexDoc ¶
Create new doc, it will auto create index mapping when index unexist.
func (*ESClient) CreateIndexMapping ¶
Create the new index and setting index mapping, it will return error when index is exist.
The mapping param like :
mapping = ` { "mappings": { "properties": { "title": { "type": "text", "analyzer": "ik_max_word", "search_analyzer": "ik_smart" }, } } }`
func (*ESClient) IsExistIndex ¶
Check indexs whether exist
func (*ESClient) SearchIndex ¶
Search doc by query index, and set page, limit. by default page=0 and limit=10
func (*ESClient) UpdateIndexDoc ¶
Update the specified fields in the index.
The doc string like :
doc := ` { "doc": { "fields":"value" } } `
func (*ESClient) UpdateIndexMapping ¶
Update the index mapping, for exmple: add new field or update one.
The mapping param like :
mapping := ` { "properties": { "title": { "type": "text", "analyzer": "ik_max_word", "search_analyzer": "ik_smart" } } }`
type Response ¶
type Response struct { Took int `json:"took"` TimeOut bool `json:"timed_out"` Shards *Shards `json:"_shards"` Hits *SearchHits `json:"hits"` Aggregations *Aggregations `json:"aggregations"` }
type SearchHit ¶
type SearchHit struct { Index string `json:"_index"` ID string `json:"_id"` Score *float64 `json:"_score,omitempty"` // computed score Source json.RawMessage `json:"_source,omitempty"` // stored document source }
type SearchHits ¶
Click to show internal directories.
Click to hide internal directories.