Documentation
¶
Index ¶
- type BoolQuery
- type CountResponse
- type DeleteResponse
- type ElasticsearchClient
- func (c *ElasticsearchClient) Count(indexName string) (*CountResponse, error)
- func (c *ElasticsearchClient) Delete(indexName, id string) (*DeleteResponse, error)
- func (c *ElasticsearchClient) Get(indexName, id string) (*GetResponse, error)
- func (c *ElasticsearchClient) Index(indexName, id string, data interface{}) (*InsertResponse, error)
- func (c *ElasticsearchClient) Search(indexName string, query *SearchRequest) (*SearchResponse, error)
- func (c *ElasticsearchClient) SearchWithRawQueryDSL(indexName string, queryDSL []byte) (*SearchResponse, error)
- type ElasticsearchConfig
- type GetResponse
- type InsertResponse
- type MatchQuery
- type Query
- type QueryStringQuery
- type RangeQuery
- type SearchRequest
- type SearchResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BoolQuery ¶
type BoolQuery struct {
Must []interface{} `json:"must,omitempty"`
MustNot []interface{} `json:"must_not,omitempty"`
Should []interface{} `json:"should,omitempty"`
}
BoolQuery wrapper queries
type CountResponse ¶
type CountResponse struct {
Count int `json:"count"`
}
CountResponse is a count response object
type DeleteResponse ¶
type DeleteResponse struct {
Found bool `json:"found"`
Result bool `json:"result"`
Index string `json:"_index"`
Type string `json:"_type"`
ID string `json:"_id"`
Version int `json:"_version"`
}
DeleteResponse is a delete response object
type ElasticsearchClient ¶
type ElasticsearchClient struct {
Config *ElasticsearchConfig
}
ElasticsearchClient elasticsearch client api
func (*ElasticsearchClient) Count ¶
func (c *ElasticsearchClient) Count(indexName string) (*CountResponse, error)
Count used to count how many docs in one index
func (*ElasticsearchClient) Delete ¶
func (c *ElasticsearchClient) Delete(indexName, id string) (*DeleteResponse, error)
Delete used to delete document by id
func (*ElasticsearchClient) Get ¶
func (c *ElasticsearchClient) Get(indexName, id string) (*GetResponse, error)
Get fetch document by id
func (*ElasticsearchClient) Index ¶
func (c *ElasticsearchClient) Index(indexName, id string, data interface{}) (*InsertResponse, error)
IndexDoc index a document into elasticsearch
func (*ElasticsearchClient) Search ¶
func (c *ElasticsearchClient) Search(indexName string, query *SearchRequest) (*SearchResponse, error)
Search used to execute a search query
func (*ElasticsearchClient) SearchWithRawQueryDSL ¶
func (c *ElasticsearchClient) SearchWithRawQueryDSL(indexName string, queryDSL []byte) (*SearchResponse, error)
type ElasticsearchConfig ¶
type ElasticsearchConfig struct {
Endpoint string `config:"endpoint"`
IndexPrefix string `config:"index_prefix"`
Username string `config:"username"`
Password string `config:"password"`
}
ElasticsearchConfig contains common settings for elasticsearch
type GetResponse ¶
type GetResponse struct {
Found bool `json:"found"`
Index string `json:"_index"`
Type string `json:"_type"`
ID string `json:"_id"`
Version int `json:"_version"`
Source map[string]interface{} `json:"_source"`
}
GetResponse is a get response object
type InsertResponse ¶
type InsertResponse struct {
Created bool `json:"created"`
Index string `json:"_index"`
Type string `json:"_type"`
ID string `json:"_id"`
Version int `json:"_version"`
}
InsertResponse is a index response object
type MatchQuery ¶
type MatchQuery struct {
Match map[string]interface{} `json:"match,omitempty"`
}
func (*MatchQuery) Set ¶
func (match *MatchQuery) Set(field string, v interface{})
Init match query's condition
type Query ¶
type Query struct {
BoolQuery *BoolQuery `json:"bool"`
}
Query is the root query object
type QueryStringQuery ¶
type QueryStringQuery struct {
Query map[string]interface{} `json:"query_string,omitempty"`
}
func NewQueryString ¶
func NewQueryString(q string) *QueryStringQuery
func (*QueryStringQuery) DefaultOperator ¶
func (query *QueryStringQuery) DefaultOperator(op string)
func (*QueryStringQuery) Fields ¶
func (query *QueryStringQuery) Fields(fields ...string)
func (*QueryStringQuery) QueryString ¶
func (query *QueryStringQuery) QueryString(q string)
type RangeQuery ¶
RangeQuery is used to find value in range
func (*RangeQuery) Gt ¶
func (query *RangeQuery) Gt(field string, value interface{})
func (*RangeQuery) Gte ¶
func (query *RangeQuery) Gte(field string, value interface{})
func (*RangeQuery) Lt ¶
func (query *RangeQuery) Lt(field string, value interface{})
func (*RangeQuery) Lte ¶
func (query *RangeQuery) Lte(field string, value interface{})
type SearchRequest ¶
type SearchRequest struct {
Query *Query `json:"query,omitempty"`
From int `json:"from"`
Size int `json:"size"`
Sort *[]interface{} `json:"sort,omitempty"`
}
SearchRequest is the root search query object
func (*SearchRequest) AddSort ¶
func (request *SearchRequest) AddSort(field string, order string)
AddSort add sort conditions to SearchRequest
type SearchResponse ¶
type SearchResponse struct {
Took int `json:"took"`
TimedOut bool `json:"timed_out"`
Hits struct {
Total int `json:"total"`
MaxScore float32 `json:"max_score"`
Hits []model.IndexDocument `json:"hits,omitempty"`
} `json:"hits"`
Aggregations map[string]model.Aggregation `json:"aggregations,omitempty"`
}
SearchResponse is a count response object