index

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2018 License: Apache-2.0 Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

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 {
	Result  string `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 {
	Result  string `json:"result"`
	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

type RangeQuery struct {
	Range map[string]map[string]interface{} `json:"range,omitempty"`
}

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

Jump to

Keyboard shortcuts

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