eneru

package module
v0.0.0-...-b10bda1 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2015 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GET    = "GET"
	POST   = "POST"
	PUT    = "PUT"
	DELETE = "DELETE"
	HEAD   = "HEAD"
)

Variables

View Source
var (
	ErrUnableConnect = errors2.NewInternal("unable to connect elastic search")
)

Functions

func NewJson

func NewJson(fn ObjectFunc) *bytes.Buffer

func NewJsonString

func NewJsonString(s string) *bytes.Buffer

Types

type Aggregations

type Aggregations map[string]*json.RawMessage

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(url string, poolSize int) (*Client, error)

func (*Client) Count

func (c *Client) Count() *CountReq

func (*Client) CreateIndex

func (c *Client) CreateIndex(index string) *CreateIndexReq

func (*Client) CreateMapping

func (c *Client) CreateMapping(index, ty string) *CreateMappingReq

func (*Client) Debug

func (c *Client) Debug(debug bool)

func (*Client) Delete

func (c *Client) Delete(index string) *DeleteReq

func (*Client) DeleteMapping

func (c *Client) DeleteMapping(index, ty string) *DeleteMappingReq

func (*Client) ExistIndex

func (c *Client) ExistIndex(index string) *ExistIndexReq

func (*Client) GetMapping

func (c *Client) GetMapping(index, ty string) *GetMappingReq

func (*Client) Index

func (c *Client) Index(index string) *IndexReq

func (*Client) Pretty

func (c *Client) Pretty(pretty bool)

func (*Client) Request

func (c *Client) Request(method, path string, query *Query, body *bytes.Buffer) (*http.Response, error)

func (*Client) Search

func (c *Client) Search() *SearchReq

func (*Client) Update

func (c *Client) Update(index, ty string) *UpdateReq

func (*Client) UpdatePartial

func (c *Client) UpdatePartial(index, ty, id string) *UpdatePartialReq

type CountReq

type CountReq struct {
	// contains filtered or unexported fields
}

func NewCount

func NewCount(client *Client) *CountReq

func (*CountReq) Do

func (req *CountReq) Do() (int, error)

func (*CountReq) Index

func (req *CountReq) Index(index string) *CountReq

func (*CountReq) Type

func (req *CountReq) Type(ty string) *CountReq

type CountResp

type CountResp struct {
	Count int `json:"count"`
}

type CreateIndexReq

type CreateIndexReq struct {
	// contains filtered or unexported fields
}

func NewCreateIndex

func NewCreateIndex(client *Client, index string) *CreateIndexReq

func (*CreateIndexReq) Body

func (req *CreateIndexReq) Body(body *bytes.Buffer) *CreateIndexReq

func (*CreateIndexReq) Do

func (req *CreateIndexReq) Do() (*CreateIndexResp, error)

type CreateIndexResp

type CreateIndexResp struct {
	Acknowledged bool `json:"acknowledged"`
}

type CreateMappingReq

type CreateMappingReq struct {
	// contains filtered or unexported fields
}

func NewCreateMapping

func NewCreateMapping(client *Client, index, ty string) *CreateMappingReq

func (*CreateMappingReq) Body

func (req *CreateMappingReq) Body(body *bytes.Buffer) *CreateMappingReq

func (*CreateMappingReq) Do

type CreateMappingResp

type CreateMappingResp struct {
	Acknowledged bool `json:"acknowledged"`
}

type DeleteMappingReq

type DeleteMappingReq struct {
	// contains filtered or unexported fields
}

func NewDeleteMapping

func NewDeleteMapping(client *Client, index, ty string) *DeleteMappingReq

func (*DeleteMappingReq) Do

type DeleteMappingResp

type DeleteMappingResp struct {
	Acknowledged bool `json:"acknowledged"`
}

type DeleteReq

type DeleteReq struct {
	// contains filtered or unexported fields
}

func NewDelete

func NewDelete(client *Client, index string) *DeleteReq

func (*DeleteReq) Do

func (req *DeleteReq) Do() (*DeleteResp, error)

func (*DeleteReq) ID

func (req *DeleteReq) ID(id string) *DeleteReq

func (*DeleteReq) Type

func (req *DeleteReq) Type(ty string) *DeleteReq

type DeleteResp

type DeleteResp struct {
	Acknowledged bool `json:"acknowledged"`
}

type ErrorResp

type ErrorResp struct {
	Err    string `json:"error"`
	Status int    `json:"status"`
}

func (*ErrorResp) Error

func (err *ErrorResp) Error() string

type ExistIndexReq

type ExistIndexReq struct {
	// contains filtered or unexported fields
}

func NewExistIndex

func NewExistIndex(client *Client, index string) *ExistIndexReq

func (*ExistIndexReq) Do

func (req *ExistIndexReq) Do() (bool, error)

func (*ExistIndexReq) Type

func (req *ExistIndexReq) Type(ty string) *ExistIndexReq

type GetMappingReq

type GetMappingReq struct {
	// contains filtered or unexported fields
}

func NewGetMapping

func NewGetMapping(client *Client, index, ty string) *GetMappingReq

func (*GetMappingReq) Do

func (req *GetMappingReq) Do() (map[string]interface{}, error)

type IndexReq

type IndexReq struct {
	// contains filtered or unexported fields
}

func NewIndex

func NewIndex(client *Client, index string) *IndexReq

func (*IndexReq) Body

func (req *IndexReq) Body(body *bytes.Buffer) *IndexReq

func (*IndexReq) BodyJson

func (req *IndexReq) BodyJson(v interface{}) *IndexReq

func (*IndexReq) Do

func (req *IndexReq) Do() (*IndexResp, error)

func (*IndexReq) ID

func (req *IndexReq) ID(id string) *IndexReq

func (*IndexReq) Type

func (req *IndexReq) Type(ty string) *IndexReq

type IndexResp

type IndexResp struct {
	Index   string `json:"_index"`
	Type    string `json:"_type"`
	ID      string `json:"_id"`
	Version int    `json:"_version"`
	Created bool   `json:"created"`
}

type Json

type Json struct {
	// contains filtered or unexported fields
}

func (*Json) AF

func (j *Json) AF(key string, prec int, vals ...float64)

func (*Json) AI

func (j *Json) AI(key string, vals ...int)

func (*Json) AO

func (j *Json) AO(key string, fns ...ObjectFunc)

func (*Json) AS

func (j *Json) AS(key string, vals ...string)

func (*Json) B

func (j *Json) B(key string, val bool)

func (*Json) F

func (j *Json) F(key string, val float64, prec int)

func (*Json) I

func (j *Json) I(key string, val int)

func (*Json) O

func (j *Json) O(key string, fn ObjectFunc)

func (*Json) S

func (j *Json) S(key, val string)

type ObjectFunc

type ObjectFunc func(j *Json)

type Query

type Query struct {
	// contains filtered or unexported fields
}

func NewQuery

func NewQuery() *Query

func (*Query) Add

func (q *Query) Add(key, val string)

func (*Query) String

func (q *Query) String() string

type SearchExplanation

type SearchExplanation struct {
	Value       float64              `json:"value"`             // e.g. 1.0
	Description string               `json:"description"`       // e.g. "boost" or "ConstantScore(*:*), product of:"
	Details     []*SearchExplanation `json:"details,omitempty"` // recursive details
}

type SearchFacet

type SearchFacet struct {
	Type    string              `json:"_type"`
	Missing int                 `json:"missing"`
	Total   int                 `json:"total"`
	Other   int                 `json:"other"`
	Terms   []*SearchFacetTerm  `json:"terms"`
	Ranges  []*SearchFacetRange `json:"ranges"`
	Entries []*SearchFacetEntry `json:"entries"`
}

type SearchFacetEntry

type SearchFacetEntry struct {
	// Key for this facet, e.g. in histograms
	Key interface{} `json:"key"`
	// Date histograms contain the number of milliseconds as date:
	// If e.Time = 1293840000000, then: Time.at(1293840000000/1000) => 2011-01-01
	Time int64 `json:"time"`
	// Number of hits for this facet
	Count int `json:"count"`
	// Min is either a string like "Infinity" or a float64.
	// This is returned with some DateHistogram facets.
	Min interface{} `json:"min,omitempty"`
	// Max is either a string like "-Infinity" or a float64
	// This is returned with some DateHistogram facets.
	Max interface{} `json:"max,omitempty"`
	// Total is the sum of all entries on the recorded Time
	// This is returned with some DateHistogram facets.
	Total float64 `json:"total,omitempty"`
	// TotalCount is the number of entries for Total
	// This is returned with some DateHistogram facets.
	TotalCount int `json:"total_count,omitempty"`
	// Mean is the mean value
	// This is returned with some DateHistogram facets.
	Mean float64 `json:"mean,omitempty"`
}

type SearchFacetRange

type SearchFacetRange struct {
	From       float64 `json:"from"`
	FromStr    string  `json:"from_str"`
	To         float64 `json:"to"`
	ToStr      string  `json:"to_str"`
	Count      int     `json:"count"`
	Min        float64 `json:"min"`
	Max        float64 `json:"max"`
	TotalCount int     `json:"total_count"`
	Total      float64 `json:"total"`
	Mean       float64 `json:"mean"`
}

type SearchFacetTerm

type SearchFacetTerm struct {
	Term  string `json:"term"`
	Count int    `json:"count"`
}

type SearchFacets

type SearchFacets map[string]*SearchFacet

type SearchHit

type SearchHit struct {
	Score       float64                `json:"_score"`       // computed score
	Index       string                 `json:"_index"`       // index name
	ID          string                 `json:"_id"`          // external or internal
	Type        string                 `json:"_type"`        // type
	Version     int64                  `json:"_version"`     // version number, when Version is set to true in SearchService
	Sort        []interface{}          `json:"sort"`         // sort information
	Highlight   SearchHitHighlight     `json:"highlight"`    // highlighter information
	Source      *json.RawMessage       `json:"_source"`      // stored document source
	Fields      map[string]interface{} `json:"fields"`       // returned fields
	Explanation *SearchExplanation     `json:"_explanation"` // explains how the score was computed
}

type SearchHitHighlight

type SearchHitHighlight map[string][]string

type SearchHits

type SearchHits struct {
	Total    int          `json:"total"`     // total number of hits found
	MaxScore float64      `json:"max_score"` // maximum score of all hits
	Hits     []*SearchHit `json:"hits"`      // the actual hits returned
}

type SearchReq

type SearchReq struct {
	Query *Query
	// contains filtered or unexported fields
}

func NewSearch

func NewSearch(client *Client) *SearchReq

func (*SearchReq) Analyzer

func (req *SearchReq) Analyzer(a string) *SearchReq

func (*SearchReq) Body

func (req *SearchReq) Body(body *bytes.Buffer) *SearchReq

func (*SearchReq) Do

func (req *SearchReq) Do() (*SearchResp, error)

func (*SearchReq) Index

func (req *SearchReq) Index(index string) *SearchReq

func (*SearchReq) Source

func (req *SearchReq) Source(s string) *SearchReq

func (*SearchReq) Type

func (req *SearchReq) Type(ty string) *SearchReq

type SearchResp

type SearchResp struct {
	Took         int64         `json:"took"`            // search time in milliseconds
	ScrollID     string        `json:"_scroll_id"`      // only used with Scroll and Scan operations
	Hits         *SearchHits   `json:"hits"`            // the actual search hits
	Suggest      SearchSuggest `json:"suggest"`         // results from suggesters
	Facets       SearchFacets  `json:"facets"`          // results from facets
	Aggregations Aggregations  `json:"aggregations"`    // results from aggregations
	TimedOut     bool          `json:"timed_out"`       // true if the search timed out
	Error        string        `json:"error,omitempty"` // used in MultiSearch only
}

type SearchSuggest

type SearchSuggest map[string][]*SearchSuggestion

type SearchSuggestion

type SearchSuggestion struct {
	Text    string                    `json:"text"`
	Offset  int                       `json:"offset"`
	Length  int                       `json:"length"`
	Options []*SearchSuggestionOption `json:"options"`
}

type SearchSuggestionOption

type SearchSuggestionOption struct {
	Text    string      `json:"text"`
	Score   float64     `json:"score"`
	Freq    int         `json:"freq"`
	Payload interface{} `json:"payload"`
}

type UpdatePartialReq

type UpdatePartialReq struct {
	Query *Query
	// contains filtered or unexported fields
}

func NewUpdatePartial

func NewUpdatePartial(client *Client, index, ty, id string) *UpdatePartialReq

func (*UpdatePartialReq) Body

func (req *UpdatePartialReq) Body(body *bytes.Buffer) *UpdatePartialReq

func (*UpdatePartialReq) Do

type UpdatePartialResp

type UpdatePartialResp struct {
	Index   string `json:"_index"`
	Type    string `json:"_type"`
	ID      string `json:"_id"`
	Version int    `json:"_version"`
}

type UpdateReq

type UpdateReq struct {
	Query *Query
	// contains filtered or unexported fields
}

func NewUpdate

func NewUpdate(client *Client, index, ty string) *UpdateReq

func (*UpdateReq) Body

func (req *UpdateReq) Body(body *bytes.Buffer) *UpdateReq

func (*UpdateReq) Do

func (req *UpdateReq) Do() (*UpdateResp, error)

func (*UpdateReq) ID

func (req *UpdateReq) ID(id string) *UpdateReq

type UpdateResp

type UpdateResp struct {
	Index   string `json:"_index"`
	Type    string `json:"_type"`
	ID      string `json:"_id"`
	Version int    `json:"_version"`
	Created bool   `json:"created"`
}

Jump to

Keyboard shortcuts

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