Documentation
¶
Overview ¶
Package es implements a simple Elasticsearch client.
Copyright 2019 TXN2
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Index ¶
- type Client
- func (es *Client) Get(url string) (int, []byte, error)
- func (es *Client) Post(url string, data []byte) (int, Result, error)
- func (es *Client) PostObj(url string, dataObj interface{}) (int, Result, error)
- func (es *Client) PostObjUnmarshal(url string, dataObj interface{}, retObj interface{}) (int, error)
- func (es *Client) Put(url string, data []byte) (int, Result, error)
- func (es *Client) PutObj(url string, dataObj interface{}) (int, Result, error)
- func (es *Client) SendEsMapping(mapping IndexTemplate) (int, Result, error)
- type Config
- type HitsMeta
- type IndexTemplate
- type Obj
- type Result
- type SearchResults
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
Config
}
Client
func CreateClient ¶
CreateClient returns an Elasticsearch client object
func (*Client) Get ¶
Get uses HTTP Get method to retrieve data from elasticsearch returns a byte array that may be used to unmarshal into a specific type depending on the returned code.
func (*Client) PostObjUnmarshal ¶
func (es *Client) PostObjUnmarshal(url string, dataObj interface{}, retObj interface{}) (int, error)
PostObjUnmarshal Unmarshals results to retObj, likely a overridden es.SearchResults struct
func (*Client) SendEsMapping ¶ added in v1.3.4
func (es *Client) SendEsMapping(mapping IndexTemplate) (int, Result, error)
SendEsMapping
type HitsMeta ¶
type HitsMeta struct {
Total int `json:"total"`
MaxScore float64 `json:"max_score"`
Hits []Result `json:"hits"`
}
HitsMeta
type Result ¶
type Result struct {
Index string `json:"_index"`
Type string `json:"_type"`
Id string `json:"_id"`
Version int `json:"_version"`
ResultType string `json:"result"`
Found bool `json:"found"`
Shards struct {
Total int `json:"total"`
Successful int `json:"successful"`
Failed int `json:"failed"`
} `json:"_shards"`
SeqNo int `json:"_seq_no"`
PrimaryTerm int `json:"_primary_term"`
Source map[string]interface{} `json:"_source"`
Error string `json:"error"`
Status int `json:"status"`
}
Result
type SearchResults ¶
type SearchResults struct {
Took int `json:"took"`
TimedOut bool `json:"timed_out"`
Shards struct {
Total int `json:"total"`
Successful int `json:"successful"`
Skipped int `json:"skipped"`
Failed int `json:"failed"`
} `json:"_shards"`
Hits HitsMeta `json:"hits"`
Error string `json:"error"`
Status int `json:"status"`
}
SearchResults
Click to show internal directories.
Click to hide internal directories.
