elastigo

package
v0.0.0-...-e7436a2 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2017 License: Apache-2.0 Imports: 20 Imported by: 3

Documentation

Overview

Copyright 2013 Matthew Baird 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.

Copyright 2013 Matthew Baird 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

Examples

Constants

View Source
const (
	Version         = "0.0.2"
	DefaultProtocol = "http"
	DefaultDomain   = "localhost"
	DefaultPort     = "9200"
	// A decay duration of zero results in the default behaviour
	DefaultDecayDuration = 0
)
View Source
const (
	// Max buffer size in bytes before flushing to elasticsearch
	BulkMaxBuffer = 16384
	// Max number of Docs to hold in buffer before forcing flush
	BulkMaxDocs = 100
	// Max delay before forcing a flush to Elasticearch
	BulkDelaySeconds = 5
	// maximum wait shutdown seconds
	MAX_SHUTDOWN_SECS = 5
)

Variables

View Source
var ErrInvalidAliasLine = errors.New("Cannot parse aliasline")
View Source
var ErrInvalidIndexLine = errors.New("Cannot parse indexline")
View Source
var ErrInvalidShardLine = errors.New("Cannot parse shardline")
View Source
var RecordNotFound = errors.New("record not found")

404 Response.

Functions

func Escape

func Escape(args map[string]interface{}) (s string, err error)

func GetIndexUrl

func GetIndexUrl(index string, _type string, id string, parentId string, version int, op_type string,
	routing string, timestamp string, ttl int, percolate string, timeout string, refresh bool) (retval string, e error)

func ScrollDuration

func ScrollDuration(duration string) string

func WriteBulkBytes

func WriteBulkBytes(op string, index string, _type string, id, parent, ttl string, date *time.Time, data interface{}) ([]byte, error)

Given a set of arguments for index, type, id, data create a set of bytes that is formatted for bulkd index http://www.elasticsearch.org/guide/reference/api/bulk.html

Types

type AggregateDsl

type AggregateDsl struct {
	Name          string
	TypeName      string
	Type          interface{}
	Filters       *FilterWrap              `json:"filters,omitempty"`
	AggregatesVal map[string]*AggregateDsl `json:"aggregations,omitempty"`
}

func Aggregate

func Aggregate(name string) *AggregateDsl

func (*AggregateDsl) Aggregates

func (d *AggregateDsl) Aggregates(aggs ...*AggregateDsl) *AggregateDsl

*

  • Aggregates accepts n "sub-aggregates" to be applied to this aggregate *
  • agg := Aggregate("user").Term("user_id")
  • agg.Aggregates(
  • Aggregate("total_spent").Sum("price"),
  • Aggregate("total_saved").Sum("discount"),
  • )

func (*AggregateDsl) Avg

func (d *AggregateDsl) Avg(field string) *AggregateDsl

func (*AggregateDsl) Cardinality

func (d *AggregateDsl) Cardinality(field string, rehash bool, threshold int) *AggregateDsl

*

  • Cardinality(
  • "field_name",
  • true,
  • 0,
  • )

func (*AggregateDsl) DateHistogram

func (d *AggregateDsl) DateHistogram(field, interval string) *AggregateDsl

func (*AggregateDsl) ExtendedStats

func (d *AggregateDsl) ExtendedStats(field string) *AggregateDsl

func (*AggregateDsl) Filter

func (d *AggregateDsl) Filter(filters ...interface{}) *AggregateDsl

func (*AggregateDsl) Global

func (d *AggregateDsl) Global() *AggregateDsl

func (*AggregateDsl) Histogram

func (d *AggregateDsl) Histogram(field string, interval int) *AggregateDsl

func (*AggregateDsl) MarshalJSON

func (d *AggregateDsl) MarshalJSON() ([]byte, error)

func (*AggregateDsl) Max

func (d *AggregateDsl) Max(field string) *AggregateDsl

func (*AggregateDsl) Min

func (d *AggregateDsl) Min(field string) *AggregateDsl

func (*AggregateDsl) Missing

func (d *AggregateDsl) Missing(field string) *AggregateDsl

func (*AggregateDsl) Percentiles

func (d *AggregateDsl) Percentiles(field string) *AggregateDsl

func (*AggregateDsl) SignificantTerms

func (d *AggregateDsl) SignificantTerms(field string) *AggregateDsl

func (*AggregateDsl) Stats

func (d *AggregateDsl) Stats(field string) *AggregateDsl

func (*AggregateDsl) Sum

func (d *AggregateDsl) Sum(field string) *AggregateDsl

func (*AggregateDsl) Terms

func (d *AggregateDsl) Terms(field string) *AggregateDsl

func (*AggregateDsl) TermsWithSize

func (d *AggregateDsl) TermsWithSize(field string, size int) *AggregateDsl

func (*AggregateDsl) ValueCount

func (d *AggregateDsl) ValueCount(field string) *AggregateDsl

type AllocateCommand

type AllocateCommand struct {
	Index        string `json:"index"`
	Shard        string `json:"shard"`
	Node         string `json:"node"`
	AllowPrimary bool   `json:"allow_primary,omitempty"`
}

type AnalyzeResponse

type AnalyzeResponse struct {
	Tokens []Token `json:"tokens"`
}

type AnalyzerOptions

type AnalyzerOptions struct {
	Path  string `json:"path,omitempty"`
	Index string `json:"index,omitempty"`
}

type BaseResponse

type BaseResponse struct {
	Ok      bool             `json:"ok"`
	Index   string           `json:"_index,omitempty"`
	Type    string           `json:"_type,omitempty"`
	Id      string           `json:"_id,omitempty"`
	Source  *json.RawMessage `json:"_source,omitempty"` // depends on the schema you've defined
	Version int              `json:"_version,omitempty"`
	Found   bool             `json:"found,omitempty"`
	Exists  bool             `json:"exists,omitempty"`
	Created bool             `json:"created,omitempty"`
	Matches []string         `json:"matches,omitempty"` // percolate matches
}

type BoolClause

type BoolClause string

BoolClause represents aa bool (and/or) clause for use with FilterWrap Legacy, use new FilterOp functions instead

type BulkIndexer

type BulkIndexer struct {

	// We are creating a variable defining the func responsible for sending
	// to allow a mock sendor for test purposes
	Sender func(*bytes.Buffer) error

	// The refresh parameter can be set to true in order to refresh the
	// relevant primary and replica shards immediately after the bulk
	// operation has occurred
	Refresh bool

	// If we encounter an error in sending, we are going to retry for this long
	// before returning an error
	// if 0 it will not retry
	RetryForSeconds int

	// channel for getting errors
	ErrorChannel chan *ErrorBuffer

	// Buffer for Max number of time before forcing flush
	BufferDelayMax time.Duration
	// Max buffer size in bytes before flushing to elasticsearch
	BulkMaxBuffer int // 1048576
	// Max number of Docs to hold in buffer before forcing flush
	BulkMaxDocs int // 100
	// contains filtered or unexported fields
}

A bulk indexer creates goroutines, and channels for connecting and sending data to elasticsearch in bulk, using buffers.

Example (Responses)

The inspecting the response

package main

import (
	"bytes"
	"fmt"
	"strconv"

	elastigo "github.com/mattbaird/elastigo/lib"
)

func main() {
	c := elastigo.NewConn()

	indexer := c.NewBulkIndexer(10)
	// Create a custom Sender Func, to allow inspection of response/error
	indexer.Sender = func(buf *bytes.Buffer) error {
		// @buf is the buffer of docs about to be written
		respJson, err := c.DoCommand("POST", "/_bulk", nil, buf)
		if err != nil {
			// handle it better than this
			fmt.Println(string(respJson))
		}
		return err
	}
	indexer.Start()
	for i := 0; i < 20; i++ {
		indexer.Index("twitter", "user", strconv.Itoa(i), "", "", nil, `{"name":"bob"}`)
	}
	indexer.Stop()
}
Output:

Example (Simple)

The simplest usage of background bulk indexing

package main

import (
	elastigo "github.com/mattbaird/elastigo/lib"
)

func main() {
	c := elastigo.NewConn()

	indexer := c.NewBulkIndexerErrors(10, 60)
	indexer.Start()
	indexer.Index("twitter", "user", "1", "", "", nil, `{"name":"bob"}`)
	indexer.Stop()
}
Output:

func (*BulkIndexer) Delete

func (b *BulkIndexer) Delete(index, _type, id string)

func (*BulkIndexer) Flush

func (b *BulkIndexer) Flush()

Flush all current documents to ElasticSearch

func (*BulkIndexer) Index

func (b *BulkIndexer) Index(index string, _type string, id, parent, ttl string, date *time.Time, data interface{}) error

The index bulk API adds or updates a typed JSON document to a specific index, making it searchable. it operates by buffering requests, and ocassionally flushing to elasticsearch http://www.elasticsearch.org/guide/reference/api/bulk.html

func (*BulkIndexer) NumErrors

func (b *BulkIndexer) NumErrors() uint64

func (*BulkIndexer) PendingDocuments

func (b *BulkIndexer) PendingDocuments() int

func (*BulkIndexer) Send

func (b *BulkIndexer) Send(buf *bytes.Buffer) error

This does the actual send of a buffer, which has already been formatted into bytes of ES formatted bulk data

func (*BulkIndexer) Start

func (b *BulkIndexer) Start()

Starts this bulk Indexer running, this Run opens a go routine so is Non blocking

func (*BulkIndexer) Stop

func (b *BulkIndexer) Stop()

Stop stops the bulk indexer, blocking the caller until it is complete.

func (*BulkIndexer) Update

func (b *BulkIndexer) Update(index string, _type string, id, parent, ttl string, date *time.Time, data interface{}) error

func (*BulkIndexer) UpdateWithPartialDoc

func (b *BulkIndexer) UpdateWithPartialDoc(index string, _type string, id, parent, ttl string, date *time.Time, partialDoc interface{}, upsert bool) error

func (*BulkIndexer) UpdateWithWithScript

func (b *BulkIndexer) UpdateWithWithScript(index string, _type string, id, parent, ttl string, date *time.Time, script string) error

type CPU

type CPU struct {
	Vendor           string `json:"vendor,omitempty"`
	Model            string `json:"model,omitempty"`
	Mhz              int    `json:"mhz,omitempty"`
	TotalCores       int    `json:"total_cores,omitempty"`
	TotalSockets     int    `json:"total_sockets,omitempty"`
	CoresPerSocket   int    `json:"cores_per_socket,omitempty"`
	CacheSizeInBytes int    `json:"cache_size_in_bytes,omitempty"`
}

type CancelCommand

type CancelCommand struct {
	Index        string `json:"index"`
	Shard        string `json:"shard"`
	Node         string `json:"node"`
	AllowPrimary bool   `json:"allow_primary,omitempty"`
}

type Cardinality

type Cardinality struct {
	Field              string  `json:"field"`
	PrecisionThreshold float64 `json:"precision_threshold,omitempty"`
	Rehash             bool    `json:"rehash,omitempty"`
}

type CatAliasInfo

type CatAliasInfo struct {
	Name  string
	Index string
}

func NewCatAliasInfo

func NewCatAliasInfo(aliasLine string) (catAlias *CatAliasInfo, err error)

Create an AliasInfo from the string _cat/alias would produce EX: alias alias i production production_20160405075824

type CatIndexDocs

type CatIndexDocs struct {
	Count   int64
	Deleted int64
}

type CatIndexInfo

type CatIndexInfo struct {
	Health   string
	Status   string
	Name     string
	Shards   int
	Replicas int
	Docs     CatIndexDocs
	Store    CatIndexStore
}

func NewCatIndexInfo

func NewCatIndexInfo(indexLine string) (catIndex *CatIndexInfo, err error)

Create an IndexInfo from the string _cat/indices would produce EX: health status index pri rep docs.count docs.deleted store.size pri.store.size green open logs-2015-06-19 2 0 135389346 0 53048922233 53048922233

type CatIndexStore

type CatIndexStore struct {
	Size    int64
	PriSize int64
}

type CatNodeInfo

type CatNodeInfo struct {
	Id                 string
	PID                string
	Host               string
	IP                 string
	Port               string
	Version            string
	Build              string
	JDK                string
	DiskAvail          string
	HeapCur            string
	HeapPerc           string
	HeapMax            string
	RamCur             string
	RamPerc            int16
	RamMax             string
	FileDescCur        string
	FileDescPerc       string
	FileDescMax        string
	Load               string
	UpTime             string
	NodeRole           string
	Master             string
	Name               string
	CmpltSize          string
	FieldMem           int
	FieldEvict         int
	FiltMem            int
	FiltEvict          int
	FlushTotal         int
	FlushTotalTime     string
	GetCur             string
	GetTime            string
	GetTotal           string
	GetExistsTime      string
	GetExistsTotal     string
	GetMissingTime     string
	GetMissingTotal    string
	IDCacheMemory      int
	IdxDelCur          string
	IdxDelTime         string
	IdxDelTotal        string
	IdxIdxCur          string
	IdxIdxTime         string
	IdxIdxTotal        string
	MergCur            string
	MergCurDocs        string
	MergCurSize        string
	MergTotal          string
	MergTotalDocs      string
	MergTotalSize      string
	MergTotalTime      string
	PercCur            string
	PercMem            string
	PercQueries        string
	PercTime           string
	PercTotal          string
	RefreshTotal       string
	RefreshTime        string
	SearchFetchCur     string
	SearchFetchTime    string
	SearchFetchTotal   string
	SearchOpenContexts string
	SearchQueryCur     string
	SearchQueryTime    string
	SearchQueryTotal   string
	SegCount           string
	SegMem             string
	SegIdxWriterMem    string
	SegIdxWriterMax    string
	SegVerMapMem       string
}

type CatShardInfo

type CatShardInfo struct {
	IndexName string
	Shard     int
	Primary   string
	State     string
	Docs      int64
	Store     int64
	NodeIP    string
	NodeName  string
}

func NewCatShardInfo

func NewCatShardInfo(rawCat string) (catshard *CatShardInfo, err error)

Create a CatShard from a line of the raw output of a _cat/shards

func (*CatShardInfo) String

func (s *CatShardInfo) String() string

Print shard info

type CatShards

type CatShards []CatShardInfo

func (*CatShards) String

func (s *CatShards) String() string

Stringify the shards

type Cluster

type Cluster struct {
	Name string `json:"name"`
}

type ClusterHealthResponse

type ClusterHealthResponse struct {
	ClusterName         string `json:"cluster_name"`
	Status              string `json:"status"`
	TimedOut            bool   `json:"timed_out"`
	NumberOfNodes       int    `json:"number_of_nodes"`
	NumberOfDataNodes   int    `json:"number_of_data_nodes"`
	ActivePrimaryShards int    `json:"active_primary_shards"`
	ActiveShards        int    `json:"active_shards"`
	RelocatingShards    int    `json:"relocating_shards"`
	InitializingShards  int    `json:"initializing_shards"`
	UnassignedShards    int    `json:"unassigned_shards"`
}

type ClusterSettingsResponse

type ClusterSettingsResponse struct {
	Transient  map[string]int `json:"transient"`
	Persistent map[string]int `json:"persistent"`
}

type ClusterStateFilter

type ClusterStateFilter struct {
	FilterNodes        bool
	FilterRoutingTable bool
	FilterMetadata     bool
	FilterBlocks       bool
	FilterIndices      []string
}

func (ClusterStateFilter) Parameterize

func (f ClusterStateFilter) Parameterize() []string

type ClusterStateIndiceResponse

type ClusterStateIndiceResponse struct {
	State string `json:"state"`
}

type ClusterStateMetadataResponse

type ClusterStateMetadataResponse struct {
	// TODO: templates
	Indices map[string]ClusterStateIndiceResponse `json:"indices"`
}

type ClusterStateNodeResponse

type ClusterStateNodeResponse struct {
	Name             string `json:"name"`
	TransportAddress string `json:"transport_address"`
}

type ClusterStateResponse

type ClusterStateResponse struct {
	ClusterName string                              `json:"cluster_name"`
	MasterNode  string                              `json:"master_node"`
	Nodes       map[string]ClusterStateNodeResponse `json:"nodes"`
	Metadata    ClusterStateMetadataResponse        `json:"metadata"`
}

type ClusterStateRoutingTableResponse

type ClusterStateRoutingTableResponse struct {
}

type Commands

type Commands struct {
	Commands []interface{} `json:"commands"`
}

type Conn

type Conn struct {
	// Maintain these for backwards compatibility
	Protocol       string
	Domain         string
	ClusterDomains []string
	Port           string
	Username       string
	Password       string
	Hosts          []string
	Gzip           bool
	RequestTracer  func(method, url, body string)

	// To compute the weighting scores, we perform a weighted average of recent response times,
	// over the course of `DecayDuration`. DecayDuration may be set to 0 to use the default
	// value of 5 minutes. The EpsilonValueCalculator uses this to calculate a score
	// from the weighted average response time.
	DecayDuration time.Duration
	// contains filtered or unexported fields
}

func NewConn

func NewConn() *Conn

func (*Conn) AddAlias

func (c *Conn) AddAlias(index string, alias string) (BaseResponse, error)

The API allows you to create an index alias through an API.

func (*Conn) AllNodesInfo

func (c *Conn) AllNodesInfo() (NodeInfo, error)

The cluster nodes info API allows to retrieve one or more (or all) of the cluster nodes information. information can be one of jvm, process

func (*Conn) AnalyzeIndices

func (c *Conn) AnalyzeIndices(index string, args map[string]interface{}) (AnalyzeResponse, error)

AnalyzeIndices performs the analysis process on a text and return the tokens breakdown of the text. http://www.elasticsearch.org/guide/reference/api/admin-indices-analyze/

func (*Conn) ClearCache

func (c *Conn) ClearCache(clearId bool, clearBloom bool, args map[string]interface{}, indices ...string) (ExtendedStatus, error)

ClearCache allows to clear either all caches or specific cached associated with one ore more indices. see http://www.elasticsearch.org/guide/reference/api/admin-indices-clearcache/

func (*Conn) Close

func (c *Conn) Close()

func (*Conn) CloseIndex

func (c *Conn) CloseIndex(index string) (BaseResponse, error)

func (*Conn) CloseIndices

func (c *Conn) CloseIndices() (BaseResponse, error)

func (*Conn) ClusterState

func (c *Conn) ClusterState(filter ClusterStateFilter) (ClusterStateResponse, error)

func (*Conn) Count

func (c *Conn) Count(index string, _type string, args map[string]interface{}, query interface{}) (CountResponse, error)

Count allows the caller to easily execute a query and get the number of matches for that query. It can be executed across one or more indices and across one or more types. The query can either be provided using a simple query string as a parameter, or using the Query DSL defined within the request body. http://www.elasticsearch.org/guide/reference/api/count.html

func (*Conn) CreateIndex

func (c *Conn) CreateIndex(index string) (BaseResponse, error)

The create API allows you to create an indices through an API.

func (*Conn) CreateIndexWithSettings

func (c *Conn) CreateIndexWithSettings(index string, settings interface{}) (BaseResponse, error)

The create API allows you to create an indices through an API.

func (*Conn) CreateSnapshotRepository

func (c *Conn) CreateSnapshotRepository(name string, args map[string]interface{}, settings interface{}) (BaseResponse, error)

CreateSnapshotRepository creates a new snapshot repository on the cluster http://www.elastic.co/guide/en/elasticsearch/reference/1.3/modules-snapshots.html

func (*Conn) Delete

func (c *Conn) Delete(index string, _type string, id string, args map[string]interface{}) (BaseResponse, error)

Delete API allows to delete a typed JSON document from a specific index based on its id. http://www.elasticsearch.org/guide/reference/api/delete.html

func (*Conn) DeleteByQuery

func (c *Conn) DeleteByQuery(indices []string, types []string, args map[string]interface{}, query interface{}) (BaseResponse, error)

DeleteByQuery allows the caller to delete documents from one or more indices and one or more types based on a query. The query can either be provided using a simple query string as a parameter, or using the Query DSL defined within the request body. see: http://www.elasticsearch.org/guide/reference/api/delete-by-query.html

func (*Conn) DeleteIndex

func (c *Conn) DeleteIndex(index string) (BaseResponse, error)

The delete API allows you to delete one or more indices through an API. This operation may fail if the elasticsearch configuration has been set to forbid deleting indexes.

func (*Conn) DeleteMapping

func (c *Conn) DeleteMapping(index string, typeName string) (BaseResponse, error)

The delete API allows you to delete a mapping through an API.

func (*Conn) DoCommand

func (c *Conn) DoCommand(method string, url string, args map[string]interface{}, data interface{}) ([]byte, error)

func (*Conn) Exists

func (c *Conn) Exists(index string, _type string, id string, args map[string]interface{}) (BaseResponse, error)

Exists allows the caller to check for the existence of a document using HEAD This appears to be broken in the current version of elasticsearch 0.19.10, currently returning nothing

func (*Conn) ExistsBool

func (c *Conn) ExistsBool(index string, _type string, id string, args map[string]interface{}) (bool, error)

ExistsBool allows caller to check for the existence of a document using HEAD TODO(shutej): This looks redundant with the Exists function in baserequest.go, check with mattbaird@.

func (*Conn) ExistsIndex

func (c *Conn) ExistsIndex(index string, _type string, args map[string]interface{}) (bool, error)

ExistsIndex allows caller to check for the existence of an index or a type using HEAD

func (*Conn) Explain

func (c *Conn) Explain(index string, _type string, id string, args map[string]interface{}, query string) (Match, error)

Explain computes a score explanation for a query and a specific document. This can give useful feedback whether a document matches or didn’t match a specific query. This feature is available from version 0.19.9 and up. see http://www.elasticsearch.org/guide/reference/api/explain.html

func (*Conn) Flush

func (c *Conn) Flush(indices ...string) (BaseResponse, error)

Flush flushes one or more indices through an API. The flush process of an index basically frees memory from the index by flushing data to the index storage and clearing the internal transaction log. By default, ElasticSearch uses memory heuristics in order to automatically trigger flush operations as required in order to clear memory. http://www.elasticsearch.org/guide/reference/api/admin-indices-flush.html TODO: add Shards to response

func (*Conn) Get

func (c *Conn) Get(index string, _type string, id string, args map[string]interface{}) (BaseResponse, error)

The get API allows to get a typed JSON document from the index based on its id. GET - retrieves the doc HEAD - checks for existence of the doc http://www.elasticsearch.org/guide/reference/api/get.html TODO: make this implement an interface

func (*Conn) GetCatAliasInfo

func (c *Conn) GetCatAliasInfo(pattern string) (catAliases []CatAliasInfo)

Pull all the alias info from the connection

func (*Conn) GetCatIndexInfo

func (c *Conn) GetCatIndexInfo(pattern string) (catIndices []CatIndexInfo)

Pull all the index info from the connection

func (*Conn) GetCatNodeInfo

func (c *Conn) GetCatNodeInfo(fields []string) (catNodes []CatNodeInfo, err error)

GetCatNodeInfo issues an elasticsearch cat nodes request with the specified fields and returns a list of CatNodeInfos, one for each node, whose requested members are populated with statistics. If fields is nil or empty, the default cat output is used. NOTE: if you include the name field, make sure it is the last field in the list, because name values can contain spaces which screw up the parsing

func (*Conn) GetCatShards

func (c *Conn) GetCatShards() (shards CatShards)

Get all the shards, even the bad ones

func (*Conn) GetCustom

func (c *Conn) GetCustom(index string, _type string, id string, args map[string]interface{}, source *json.RawMessage) (BaseResponse, error)

Same as Get but with custom source type.

func (*Conn) GetSnapshotByName

func (c *Conn) GetSnapshotByName(repository, name string, args map[string]interface{}) (GetSnapshotsResponse, error)

GetSnapshots returns all snapshot of the specified name for a specific repository http://www.elastic.co/guide/en/elasticsearch/reference/1.3/modules-snapshots.html

func (*Conn) GetSnapshots

func (c *Conn) GetSnapshots(repository string, args map[string]interface{}) (GetSnapshotsResponse, error)

GetSnapshots returns all snapshot for a specific repository http://www.elastic.co/guide/en/elasticsearch/reference/1.3/modules-snapshots.html

func (*Conn) GetSource

func (c *Conn) GetSource(index string, _type string, id string, args map[string]interface{}, source interface{}) error

GetSource retrieves the document by id and converts it to provided interface

func (*Conn) Health

func (c *Conn) Health(indices ...string) (ClusterHealthResponse, error)

The cluster health API allows to get a very simple status on the health of the cluster. see http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/cluster-health.html TODO: implement wait_for_status, timeout, wait_for_relocating_shards, wait_for_nodes TODO: implement level (Can be one of cluster, indices or shards. Controls the details level of the health information returned. Defaults to cluster.)

func (*Conn) Index

func (c *Conn) Index(index string, _type string, id string, args map[string]interface{}, data interface{}) (BaseResponse, error)

Index adds or updates a typed JSON document in a specific index, making it searchable, creating an index if it did not exist. if id is omited, op_type 'create' will be passed and http method will default to "POST" _type is optional id is optional parentId is optional version is optional op_type is optional routing is optional timestamp is optional ttl is optional percolate is optional timeout is optional http://www.elasticsearch.org/guide/reference/api/index_.html

func (*Conn) IndexWithParameters

func (c *Conn) IndexWithParameters(index string, _type string, id string, parentId string, version int, op_type string,
	routing string, timestamp string, ttl int, percolate string, timeout string, refresh bool,
	args map[string]interface{}, data interface{}) (BaseResponse, error)

IndexWithParameters takes all the potential parameters available

func (*Conn) IndicesExists

func (c *Conn) IndicesExists(indices ...string) (bool, error)

IndicesExists checks for the existence of indices. uses RecordNotFound message if it doesn't exist and "no error" situation if it exists. If there is some other error, gives the error and says it exists just in case see http://www.elasticsearch.org/guide/reference/api/admin-indices-indices-exists/

func (*Conn) MGet

func (c *Conn) MGet(index string, _type string, mgetRequest MGetRequestContainer, args map[string]interface{}) (MGetResponseContainer, error)

MGet allows the caller to get multiple documents based on an index, type (optional) and id (and possibly routing). The response includes a docs array with all the fetched documents, each element similar in structure to a document provided by the get API. see http://www.elasticsearch.org/guide/reference/api/multi-get.html

func (*Conn) MoreLikeThis

func (c *Conn) MoreLikeThis(index string, _type string, id string, args map[string]interface{}, query MoreLikeThisQuery) (BaseResponse, error)

MoreLikeThis allows the caller to get documents that are “like” a specified document. http://www.elasticsearch.org/guide/reference/api/more-like-this.html

func (*Conn) NewBulkIndexer

func (c *Conn) NewBulkIndexer(maxConns int) *BulkIndexer

func (*Conn) NewBulkIndexerErrors

func (c *Conn) NewBulkIndexerErrors(maxConns, retrySeconds int) *BulkIndexer

A bulk indexer with more control over error handling

 @maxConns is the max number of in flight http requests
 @retrySeconds is # of seconds to wait before retrying falied requests

done := make(chan bool)
BulkIndexerGlobalRun(100, done)

func (*Conn) NewRequest

func (c *Conn) NewRequest(method, path, query string) (*Request, error)

func (*Conn) NodesInfo

func (c *Conn) NodesInfo(information []string, nodes ...string) (NodeInfo, error)

func (*Conn) NodesShutdown

func (c *Conn) NodesShutdown(delay int, nodes ...string) error

NodesShutdown allows the caller to shutdown between one and all nodes in the cluster delay is a integer representing number of seconds passing "" or "_all" for the nodes parameter will shut down all nodes see http://www.elasticsearch.org/guide/reference/api/admin-cluster-nodes-shutdown/

func (*Conn) NodesStats

func (c *Conn) NodesStats() (NodeStatsResponse, error)

func (*Conn) OpenIndex

func (c *Conn) OpenIndex(index string) (BaseResponse, error)

func (*Conn) OpenIndices

func (c *Conn) OpenIndices() (BaseResponse, error)

func (*Conn) OptimizeIndices

func (c *Conn) OptimizeIndices(args map[string]interface{}, indices ...string) (ExtendedStatus, error)

AnalyzeIndices performs the analysis process on a text and return the tokens breakdown of the text. http://www.elasticsearch.org/guide/reference/api/admin-indices-analyze/

func (*Conn) Percolate

func (c *Conn) Percolate(index string, _type string, name string, args map[string]interface{}, doc string) (PercolatorResult, error)

func (*Conn) PutMapping

func (c *Conn) PutMapping(index string, typeName string, instance interface{}, opt MappingOptions) error

func (*Conn) PutMappingFromJSON

func (c *Conn) PutMappingFromJSON(index string, typeName string, mapping []byte) error

Same as PutMapping, but takes a []byte for mapping and provides no check of structure

func (*Conn) PutSettings

func (c *Conn) PutSettings(index string, settings interface{}) (BaseResponse, error)

func (*Conn) Refresh

func (c *Conn) Refresh(indices ...string) (BaseResponse, error)

Refresh explicitly refreshes one or more index, making all operations performed since the last refresh available for search. The (near) real-time capabilities depend on the index engine used. For example, the internal one requires refresh to be called, but by default a refresh is scheduled periodically. http://www.elasticsearch.org/guide/reference/api/admin-indices-refresh.html TODO: add Shards to response

func (*Conn) RegisterPercolate

func (c *Conn) RegisterPercolate(index string, id string, data interface{}) (BaseResponse, error)

See http://www.elasticsearch.org/guide/reference/api/percolate.html

func (*Conn) Reroute

func (c *Conn) Reroute(dryRun bool, commands Commands) (ClusterHealthResponse, error)

The cluster health API allows to get a very simple status on the health of the cluster. see http://www.elasticsearch.org/guide/reference/api/admin-cluster-health.html information returned. Defaults to cluster.)

func (*Conn) RestoreSnapshot

func (c *Conn) RestoreSnapshot(repository, name string, args map[string]interface{}, query interface{}) (BaseResponse, error)

RestoreSnapshot restores a snapshot of the current state of the cluster with a specific name and for a existing repositoriy http://www.elastic.co/guide/en/elasticsearch/reference/1.3/modules-snapshots.html

func (*Conn) Scroll

func (c *Conn) Scroll(args map[string]interface{}, scroll_id string) (SearchResult, error)

func (*Conn) Search

func (c *Conn) Search(index string, _type string, args map[string]interface{}, query interface{}) (SearchResult, error)

Search performs a very basic search on an index via the request URI API.

params:

@index:  the elasticsearch index
@_type:  optional ("" if not used) search specific type in this index
@args:   a map of URL parameters. Allows all the URI-request parameters allowed by ElasticSearch.
@query:  this can be one of 3 types:
           1)  string value that is valid elasticsearch
           2)  io.Reader that can be set in body (also valid elasticsearch string syntax..)
           3)  other type marshalable to json (also valid elasticsearch json)

out, err := Search(true, "github", map[string]interface{} {"from" : 10}, qryType)

http://www.elasticsearch.org/guide/reference/api/search/uri-request.html

func (*Conn) SearchUri

func (c *Conn) SearchUri(index, _type string, args map[string]interface{}) (SearchResult, error)

SearchUri performs the simplest possible query in url string params:

@index:  the elasticsearch index
@_type:  optional ("" if not used) search specific type in this index
@args: a map of URL parameters. Most important one is q

out, err := SearchUri("github","", map[string]interface{} { "q" : `user:kimchy`})

produces a request like this: host:9200/github/_search?q=user:kimchy"

http://www.elasticsearch.org/guide/reference/api/search/uri-request.html

func (*Conn) SetFromUrl

func (c *Conn) SetFromUrl(u string) error

func (*Conn) SetHosts

func (c *Conn) SetHosts(newhosts []string)

func (*Conn) SetPort

func (c *Conn) SetPort(port string)

func (*Conn) Snapshot

func (c *Conn) Snapshot(indices ...string) (ExtendedStatus, error)

Snapshot allows to explicitly perform a snapshot through the gateway of one or more indices (backup them). By default, each index gateway periodically snapshot changes, though it can be disabled and be controlled completely through this API. see http://www.elasticsearch.org/guide/reference/api/admin-indices-gateway-snapshot/

func (*Conn) Status

func (c *Conn) Status(args map[string]interface{}, indices ...string) (BaseResponse, error)

Status lists status details of all indices or the specified index. http://www.elasticsearch.org/guide/reference/api/admin-indices-status.html

func (*Conn) Suggest

func (c *Conn) Suggest(index string, args map[string]interface{}, query interface{}) (SuggestResults, error)

func (*Conn) TakeSnapshot

func (c *Conn) TakeSnapshot(repository, name string, args map[string]interface{}, query interface{}) (BaseResponse, error)

TakeSnapshot takes a snapshot of the current state of the cluster with a specific name and for a existing repositoriy http://www.elastic.co/guide/en/elasticsearch/reference/1.3/modules-snapshots.html

func (*Conn) Update

func (c *Conn) Update(index string, _type string, id string, args map[string]interface{}, data interface{}) (BaseResponse, error)

Update updates a document based on a script provided. The operation gets the document (collocated with the shard) from the index, runs the script (with optional script language and parameters), and index back the result (also allows to delete, or ignore the operation). It uses versioning to make sure no updates have happened during the “get” and “reindex”. (available from 0.19 onwards). Note, this operation still means full reindex of the document, it just removes some network roundtrips and reduces chances of version conflicts between the get and the index. The _source field need to be enabled for this feature to work.

http://www.elasticsearch.org/guide/reference/api/update.html TODO: finish this, it's fairly complex

func (*Conn) UpdateSetting

func (c *Conn) UpdateSetting(args map[string]interface{}, filter_indices ...string) (ClusterStateResponse, error)

State gets the comprehensive state information for the whole cluster see http://www.elasticsearch.org/guide/reference/api/admin-cluster-state/

func (*Conn) UpdateSettings

func (c *Conn) UpdateSettings(settingType string, key string, value int) (ClusterSettingsResponse, error)

UpdateSettings allows to update cluster wide specific settings. Defaults to Transient setting Settings updated can either be persistent (applied cross restarts) or transient (will not survive a full cluster restart). http://www.elasticsearch.org/guide/reference/api/admin-cluster-update-settings.html

func (*Conn) UpdateWithPartialDoc

func (c *Conn) UpdateWithPartialDoc(index string, _type string, id string, args map[string]interface{}, doc interface{}, upsert bool) (BaseResponse, error)

UpdateWithPartialDoc updates a document based on partial document provided. The update API also support passing a partial document (since 0.20), which will be merged into the existing document (simple recursive merge, inner merging of objects, replacing core "keys/values" and arrays). If both doc and script is specified, then doc is ignored. Best is to put your field pairs of the partial document in the script itself.

http://www.elasticsearch.org/guide/reference/api/update.html

func (*Conn) UpdateWithScript

func (c *Conn) UpdateWithScript(index string, _type string, id string, args map[string]interface{}, script string, params interface{}) (BaseResponse, error)

UpdateWithScript updates a document based on a script provided. The operation gets the document (collocated with the shard) from the index, runs the script (with optional script language and parameters), and index back the result (also allows to delete, or ignore the operation). It uses versioning to make sure no updates have happened during the "get" and "reindex". (available from 0.19 onwards).

Note, this operation still means full reindex of the document, it just removes some network roundtrips and reduces chances of version conflicts between the get and the index. The _source field need to be enabled for this feature to work. http://www.elasticsearch.org/guide/reference/api/update.html

func (*Conn) Validate

func (c *Conn) Validate(index string, _type string, args map[string]interface{}) (BaseResponse, error)

Validate allows a user to validate a potentially expensive query without executing it. see http://www.elasticsearch.org/guide/reference/api/validate.html

func (*Conn) WaitForStatus

func (c *Conn) WaitForStatus(status string, timeout int, indices ...string) (ClusterHealthResponse, error)

type CountResponse

type CountResponse struct {
	Count int    `json:"count"`
	Shard Status `json:"_shards"`
}

type DateHistogram

type DateHistogram struct {
	Field    string `json:"field"`
	Interval string `json:"interval"`
}

type DeleteByQueryResponse

type DeleteByQueryResponse struct {
	Status   bool                   `json:"ok"`
	Indicies map[string]IndexStatus `json:"_indices"`
}

type ESError

type ESError struct {
	When time.Time
	What string
	Code int
}

ESError is an error implementation that includes a time, message, and code.

func (ESError) Error

func (e ESError) Error() string

type ErrorBuffer

type ErrorBuffer struct {
	Err error
	Buf *bytes.Buffer
}

type Explaination

type Explaination struct {
	Index string `json:"index"`
	Valid bool   `json:"valid"`
	Error string `json:"error"`
}

type Explanation

type Explanation struct {
	Value       float32        `json:"value"`
	Description string         `json:"description"`
	Details     []*Explanation `json:"details,omitempty"`
}

func (*Explanation) String

func (e *Explanation) String(indent string) string

type ExtendedStatus

type ExtendedStatus struct {
	Ok           StatusBool `json:"ok"`
	ShardsStatus Status     `json:"_shards"`
}

type FacetDsl

type FacetDsl struct {
	Terms  map[string]*Term     `json:"terms,omitempty"`
	Ranges map[string]*RangeDsl `json:"terms,omitempty"`
	// contains filtered or unexported fields
}

func Facet

func Facet() *FacetDsl
"facets": {
    "terms": {
		"terms": {
			"field": [
			  "@fields.category"
			],
			"size": 25
		}
    }
}
"facets": {
  "actors": { "terms": {"field": ["actor"],"size": "10" }}
  , "langauge": { "terms": {"field": ["repository.language"],"size": "10" }}
}

func (*FacetDsl) Fields

func (m *FacetDsl) Fields(fields ...string) *FacetDsl

func (*FacetDsl) MarshalJSON

func (m *FacetDsl) MarshalJSON() ([]byte, error)

func (*FacetDsl) Range

func (m *FacetDsl) Range(r *RangeDsl) *FacetDsl

func (*FacetDsl) Regex

func (m *FacetDsl) Regex(field, match string) *FacetDsl

func (*FacetDsl) Size

func (m *FacetDsl) Size(size string) *FacetDsl

func (*FacetDsl) Term

func (m *FacetDsl) Term(t *Term) *FacetDsl

type Facets

type Facets struct {
	Tag struct {
		Terms string `json:"terms"`
	} `json:"tag"`
}

type Failure

type Failure struct {
	Index  string    `json:"index"`
	Shard  StatusInt `json:"shard"`
	Reason string    `json:"reason"`
}

func (Failure) String

func (f Failure) String() string

type FieldAggregate

type FieldAggregate struct {
	Field string `json:"field"`
	Size  *int   `json:"size,omitempty"`
}

type FilterClause

type FilterClause interface {
	String() string
}

FilterClause is either a boolClause or FilterOp for use with FilterWrap

type FilterOp

type FilterOp struct {
	TermsMap        map[string]interface{} `json:"terms,omitempty"`
	TermMap         map[string]interface{} `json:"term,omitempty"`
	RangeMap        map[string]RangeFilter `json:"range,omitempty"`
	ExistsProp      *propertyPathMarker    `json:"exists,omitempty"`
	MissingProp     *propertyPathMarker    `json:"missing,omitempty"`
	AndFilters      []*FilterOp            `json:"and,omitempty"`
	OrFilters       []*FilterOp            `json:"or,omitempty"`
	NotFilters      []*FilterOp            `json:"not,omitempty"`
	LimitProp       *LimitFilter           `json:"limit,omitempty"`
	TypeProp        *TypeFilter            `json:"type,omitempty"`
	IdsProp         *IdsFilter             `json:"ids,omitempty"`
	ScriptProp      *ScriptFilter          `json:"script,omitempty"`
	GeoDistMap      map[string]interface{} `json:"geo_distance,omitempty"`
	GeoDistRangeMap map[string]interface{} `json:"geo_distance_range,omitempty"`
}

FilterOp holds all the information for a filter query Properties should not be set directly, but instead via the fluent-style API.

func Filter

func Filter() *FilterOp

Filter creates a blank FilterOp that can be customized with further function calls This is the starting point for constructing any filter query Examples:

Filter().Term("user","kimchy")

// we use variadics to allow n arguments, first is the "field" rest are values
Filter().Terms("user", "kimchy", "elasticsearch")

Filter().Exists("repository.name")

func (*FilterOp) And

func (f *FilterOp) And(filters ...*FilterOp) *FilterOp

And will add an AND op to the filter. One or more FilterOps can be passed in.

func (*FilterOp) Exists

func (f *FilterOp) Exists(field string) *FilterOp

Exists adds an EXISTS op to the filter.

func (*FilterOp) GeoDistance

func (f *FilterOp) GeoDistance(distance string, fields ...GeoField) *FilterOp

GeoDistance will add a GEO DISTANCE op to the filter. distance: distance in ES distance format, i.e. "100km" or "100mi". fields: an array of GeoField origin coordinates. Only one coordinate needs to match.

func (*FilterOp) GeoDistanceRange

func (f *FilterOp) GeoDistanceRange(from string, to string, fields ...GeoField) *FilterOp

GeoDistanceRange will add a GEO DISTANCE RANGE op to the filter. from: minimum distance in ES distance format, i.e. "100km" or "100mi". to: maximum distance in ES distance format, i.e. "100km" or "100mi". fields: an array of GeoField origin coordinates. Only one coor

func (*FilterOp) Ids

func (f *FilterOp) Ids(ids ...interface{}) *FilterOp

Ids adds a IDS op to the filter.

func (*FilterOp) IdsByTypes

func (f *FilterOp) IdsByTypes(types []string, ids ...interface{}) *FilterOp

IdsByTypes adds a IDS op to the filter, but also allows passing in an array of types for the query.

func (*FilterOp) Limit

func (f *FilterOp) Limit(maxResults int) *FilterOp

Limit adds an LIMIT op to the filter.

func (*FilterOp) Missing

func (f *FilterOp) Missing(field string) *FilterOp

Missing adds an MISSING op to the filter.

func (*FilterOp) Not

func (f *FilterOp) Not(filters ...*FilterOp) *FilterOp

Not will add a NOT op to the filter. One or more FilterOps can be passed in.

func (*FilterOp) Or

func (f *FilterOp) Or(filters ...*FilterOp) *FilterOp

Or will add an OR op to the filter. One or more FilterOps can be passed in.

func (*FilterOp) Range

func (f *FilterOp) Range(field string, gte interface{},
	gt interface{}, lte interface{}, lt interface{}, timeZone string) *FilterOp

Range adds a range filter for the given field. See the RangeFilter struct documentation for information about the parameters.

func (*FilterOp) Term

func (f *FilterOp) Term(field string, value interface{}) *FilterOp

Term will add a term to the filter. Multiple Term filters can be added, and ES will OR them. If the term already exists in the FilterOp, the value will be overridden.

func (*FilterOp) Terms

func (f *FilterOp) Terms(field string, executionMode TermExecutionMode, values ...interface{}) *FilterOp

Terms adds a TERMS op to the filter. field: the document field executionMode Term execution mode, starts with TEM values: array of values to match Note: you can only have one terms clause in a filter. Use a bool filter to combine multiple.

func (*FilterOp) Type

func (f *FilterOp) Type(fieldType string) *FilterOp

Type adds a TYPE op to the filter.

type FilterWrap

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

FilterWrap is the legacy struct for chaining multiple filters with a bool Legacy, use new FilterOp functions instead

func CompoundFilter

func CompoundFilter(fl ...interface{}) *FilterWrap

CompoundFilter creates a complete FilterWrap given multiple filters Legacy, use new FilterOp functions instead

func NewFilterWrap

func NewFilterWrap() *FilterWrap

NewFilterWrap creates a new FilterWrap struct

func (*FilterWrap) Bool

func (f *FilterWrap) Bool(s string)

Bool sets the type of boolean filter to use. Accepted values are "and" and "or". Legacy, use new FilterOp functions instead

func (*FilterWrap) MarshalJSON

func (f *FilterWrap) MarshalJSON() ([]byte, error)

MarshalJSON override for FilterWrap to match the expected ES syntax with the bool at the root

func (*FilterWrap) String

func (f *FilterWrap) String() string

type Float32Nullable

type Float32Nullable float32

Elasticsearch returns some invalid (according to go) json, with floats having...

json: cannot unmarshal null into Go value of type float32 (see last field.)

"hits":{"total":6808,"max_score":null,

"hits":[{"_index":"10user","_type":"user","_id":"751820","_score":null,

func (*Float32Nullable) UnmarshalJSON

func (i *Float32Nullable) UnmarshalJSON(data []byte) error

type GeoField

type GeoField struct {
	GeoLocation
	Field string
}

GeoField holds a GeoLocation and a field to match to. This exists so the struct will match the ES schema.

func NewGeoField

func NewGeoField(field string, latitude float32, longitude float32) GeoField

NewGeoField is a helper function to create values for the GeoDistance filters

type GeoLocation

type GeoLocation struct {
	Latitude  float32 `json:"lat"`
	Longitude float32 `json:"lon"`
}

GeoLocation holds the coordinates for a geo query. Currently hashes are not supported.

type GetSnapshotsResponse

type GetSnapshotsResponse struct {
	Snapshots []struct {
		Snapshot  string    `json:"snapshot"`
		Indices   []string  `json:"indices"`
		State     string    `json:"state"`
		StartTime time.Time `json:"start_time"`
		EndTime   time.Time `json:"end_time"`
	} `json:"snapshots"`
}

type Highlight

type Highlight map[string][]string

type HighlightDsl

type HighlightDsl struct {
	Settings  *HighlightEmbed           `-`
	TagSchema string                    `json:"tag_schema,omitempty"`
	Fields    map[string]HighlightEmbed `json:"fields,omitempty"`
}

func NewHighlight

func NewHighlight() *HighlightDsl

func (*HighlightDsl) AddField

func (h *HighlightDsl) AddField(name string, settings *HighlightEmbed) *HighlightDsl

func (*HighlightDsl) MarshalJSON

func (t *HighlightDsl) MarshalJSON() ([]byte, error)

Custom marshalling

func (*HighlightDsl) Schema

func (h *HighlightDsl) Schema(schema string) *HighlightDsl

func (*HighlightDsl) SetOptions

func (h *HighlightDsl) SetOptions(options *HighlightEmbed) *HighlightDsl

type HighlightEmbed

type HighlightEmbed struct {
	BoundaryCharsVal   string    `json:"boundary_chars,omitempty"`
	BoundaryMaxScanVal int       `json:"boundary_max_scan,omitempty"`
	PreTags            []string  `json:"pre_tags,omitempty"`
	PostTags           []string  `json:"post_tags,omitempty"`
	FragmentSizeVal    int       `json:"fragment_size,omitempty"`
	NumOfFragmentsVal  int       `json:"number_of_fragments,omitempty"`
	HighlightQuery     *QueryDsl `json:"highlight_query,omitempty"`
	MatchedFieldsVal   []string  `json:"matched_fields,omitempty"`
	OrderVal           string    `json:"order,omitempty"`
	TypeVal            string    `json:"type,omitempty"`
}

func NewHighlightOpts

func NewHighlightOpts() *HighlightEmbed

func (*HighlightEmbed) BoundaryChars

func (o *HighlightEmbed) BoundaryChars(chars string) *HighlightEmbed

func (*HighlightEmbed) BoundaryMaxScan

func (o *HighlightEmbed) BoundaryMaxScan(max int) *HighlightEmbed

func (*HighlightEmbed) FragSize

func (he *HighlightEmbed) FragSize(size int) *HighlightEmbed

func (*HighlightEmbed) MatchedFields

func (he *HighlightEmbed) MatchedFields(fields ...string) *HighlightEmbed

func (*HighlightEmbed) NumFrags

func (he *HighlightEmbed) NumFrags(numFrags int) *HighlightEmbed

func (*HighlightEmbed) Order

func (he *HighlightEmbed) Order(order string) *HighlightEmbed

func (*HighlightEmbed) Tags

func (he *HighlightEmbed) Tags(pre string, post string) *HighlightEmbed

func (*HighlightEmbed) Type

func (he *HighlightEmbed) Type(highlightType string) *HighlightEmbed

type Histogram

type Histogram struct {
	Field    string  `json:"field"`
	Interval float64 `json:"interval"`
}

type Hit

type Hit struct {
	Index       string           `json:"_index"`
	Type        string           `json:"_type,omitempty"`
	Id          string           `json:"_id"`
	Score       Float32Nullable  `json:"_score,omitempty"` // Filters (no query) dont have score, so is null
	Source      *json.RawMessage `json:"_source"`          // marshalling left to consumer
	TTL         *TTL             `json:"_ttl,omitempty"`
	Fields      *json.RawMessage `json:"fields"` // when a field arg is passed to ES, instead of _source it returns fields
	Explanation *Explanation     `json:"_explanation,omitempty"`
	Highlight   *Highlight       `json:"highlight,omitempty"`
	Sort        []interface{}    `json:"sort,omitempty"`
}

type Hits

type Hits struct {
	Total int `json:"total"`
	//	MaxScore float32 `json:"max_score"`
	Hits []Hit `json:"hits"`
}

func (*Hits) Len

func (h *Hits) Len() int

type Http

type Http struct {
	BoundAddress   string `json:"bound_address,omitempty"`
	PublishAddress string `json:"publish_address,omitempty"`
}

type IdOptions

type IdOptions struct {
	Index string `json:"index,omitempty"`
	Path  string `json:"path,omitempty"`
}

type IdsFilter

type IdsFilter struct {
	Type   []string      `json:"type,omitempty"`
	Values []interface{} `json:"values,omitempty"`
}

IdsFilter holds the type and ids (on the _id field) to filter Type: a string or an array of string types. Optional. Values: Array of ids to match

type IndexStatus

type IndexStatus struct {
	Shards Status `json:"_shards"`
}

type Interface

type Interface struct {
	Address    string `json:"address,omitempty"`
	Name       string `json:"name,omitempty"`
	MacAddress string `json:"mac_address,omitempty"`
}

type JVM

type JVM struct {
	Pid          int      `json:"pid,omitempty"`
	Version      string   `json:"version,omitempty"`
	VMName       string   `json:"vm_name,omitempty"`
	VMVersion    string   `json:"vm_version,omitempty"`
	VMVendor     string   `json:"vm_vendor,omitempty"`
	StartTime    int      `json:"start_time,omitempty"`
	Mem          *JvmMem  `json:"mem,omitempty"`
	GcCollectors []string `json:"gc_collectors,omitempty"`
	MemoryPools  []string `json:"memory_pools,omitempty"`
}

type JsonAlias

type JsonAlias struct {
	Index string `json:"index"`
	Alias string `json:"alias"`
}

type JsonAliasAdd

type JsonAliasAdd struct {
	Add JsonAlias `json:"add"`
}

type JsonAliases

type JsonAliases struct {
	Actions []JsonAliasAdd `json:"actions"`
}

type JvmMem

type JvmMem struct {
	HeapInitInBytes    int `json:"heap_init_in_bytes,omitempty"`
	HeapMaxInBytes     int `json:"heap_max_in_bytes,omitempty"`
	NonHeapInitInBytes int `json:"non_heap_init_in_bytes,omitempty"`
	NonHeapMaxInBytes  int `json:"non_heap_max_in_bytes,omitempty"`
	DirectMaxInBytes   int `json:"direct_max_in_bytes,omitempty"`
}

type LimitFilter

type LimitFilter struct {
	Value int `json:"value"`
}

LimitFilter holds the Limit filter information Value: number of documents to limit

type MEM

type MEM struct {
	TotalInBytes int `json:"total_in_bytes,omitempty"`
}

type MGetRequest

type MGetRequest struct {
	Index  string   `json:"_index"`
	Type   string   `json:"_type"`
	ID     string   `json:"_id"`
	IDS    []string `json:"_ids,omitempty"`
	Fields []string `json:"fields,omitempty"`
}

type MGetRequestContainer

type MGetRequestContainer struct {
	Docs []MGetRequest `json:"docs"`
}

type MGetResponseContainer

type MGetResponseContainer struct {
	Docs []BaseResponse `json:"docs"`
}

type MLT

type MLT struct {
	Fields              []string `json:"fields"`
	LikeText            string   `json:"like_text"`
	PercentTermsToMatch float32  `json:"percent_terms_to_match"`
	MinTermFrequency    int      `json:"min_term_freq"`
	MaxQueryTerms       int      `json:"max_query_terms"`
	StopWords           []string `json:"stop_words"`
	MinDocFrequency     int      `json:"min_doc_freq"`
	MaxDocFrequency     int      `json:"max_doc_freq"`
	MinWordLength       int      `json:"min_word_len"`
	MaxWordLength       int      `json:"max_word_len"`
	BoostTerms          int      `json:"boost_terms"`
	Boost               float32  `json:"boost"`
	Analyzer            string   `json:"analyzer"`
}

type Mapping

type Mapping map[string]MappingOptions

func MappingForType

func MappingForType(typeName string, opts MappingOptions) Mapping

func (Mapping) Options

func (m_ Mapping) Options() MappingOptions

type MappingOptions

type MappingOptions struct {
	Id               IdOptions                `json:"_id"`
	Timestamp        TimestampOptions         `json:"_timestamp"`
	Analyzer         *AnalyzerOptions         `json:"_analyzer,omitempty"`
	Parent           *ParentOptions           `json:"_parent,omitempty"`
	Routing          *RoutingOptions          `json:"_routing,omitempty"`
	Size             *SizeOptions             `json:"_size,omitempty"`
	Source           *SourceOptions           `json:"_source,omitempty"`
	TTL              *TTLOptions              `json:"_ttl,omitempty"`
	Type             *TypeOptions             `json:"_type,omitempty"`
	Properties       map[string]interface{}   `json:"properties"`
	DynamicTemplates []map[string]interface{} `json:"dynamic_templates,omitempty"`
}

type Match

type Match struct {
	OK          bool         `json:"ok"`
	Matches     []MatchRes   `json:"matches"`
	Explanation *Explanation `json:"explanation,omitempty"`
}

type MatchAll

type MatchAll struct {
	All string `json:"-"`
}

type MatchRes

type MatchRes struct {
	Index string `json:"_index"`
	Id    string `json:"_id"`
}

type MoreLikeThisQuery

type MoreLikeThisQuery struct {
	MoreLikeThis MLT `json:"more_like_this"`
}

type MoveCommand

type MoveCommand struct {
	Index    string `json:"index"`
	Shard    string `json:"shard"`
	FromNode string `json:"from_node"`
	ToNode   string `json:"to_node"`
}

type MultiMatch

type MultiMatch struct {
	Query  string   `json:"query"`
	Fields []string `json:"fields"`
}

type Network

type Network struct {
	RefreshInterval  int        `json:"refresh_interval,omitempty"`
	PrimaryInterface *Interface `json:"primary_interface,omitempty"`
}

type Node

type Node struct {
	Name             string      `json:"name,omitempty"`
	TransportAddress string      `json:"transport_address,omitempty"`
	Host             string      `json:"host,omitempty"`
	Ip               string      `json:"ip,omitempty"`
	Version          string      `json:"version,omitempty"`
	Build            string      `json:"build,omitempty"`
	Hostname         string      `json:"hostname,omitempty"`
	HttpAddress      string      `json:"http_address,omitempty"`
	Settings         *Settings   `json:"settings,omitempty"`
	OS               *OS         `json:"os,omitempty"`
	Process          *Process    `json:"process,omitempty"`
	JVM              *JVM        `json:"jvm,omitempty"`
	ThreadPool       *ThreadPool `json:"thread_pool,omitempty"`
	Network          *Network    `json:"network,omitempty"`
	Transport        *Transport  `json:"transport,omitempty"`
	Http             *Http       `json:"http,omitempty"`
	Plugins          []*Plugin   `json:"plugins,omitempty"`
}

type NodeInfo

type NodeInfo struct {
	ClusterName string          `json:"cluster_name"`
	Nodes       map[string]Node `json:"nodes"` // node name is random string
}

type NodeStatsFSDataResponse

type NodeStatsFSDataResponse struct {
	Path          string `json:"path"`
	Mount         string `json:"mount"`
	Device        string `json:"dev"`
	Total         int64  `json:"total_in_bytes"`
	Free          int64  `json:"free_in_bytes"`
	Available     int64  `json:"available_in_bytes"`
	DiskReads     int64  `json:"disk_reads"`
	DiskWrites    int64  `json:"disk_writes"`
	DiskReadSize  int64  `json:"disk_read_size_in_bytes"`
	DiskWriteSize int64  `json:"disk_write_size_in_bytes"`
}

type NodeStatsFSResponse

type NodeStatsFSResponse struct {
	Timestamp int64                     `json:"timestamp"`
	Data      []NodeStatsFSDataResponse `json:"data"`
}

type NodeStatsFieldDataBreakerResponse

type NodeStatsFieldDataBreakerResponse struct {
	MaximumSizeInBytes   int64   `json:"maximum_size_in_bytes"`
	MaximumSize          string  `json:"maximum_size"`
	EstimatedSizeInBytes int64   `json:"estimated_size_in_bytes"`
	EstimatedSize        string  `json:"estimated_size"`
	Overhead             float64 `json:"overhead"`
	Tripped              int64   `json:"tripped"`
}

type NodeStatsHTTPResponse

type NodeStatsHTTPResponse struct {
	CurrentOpen int64 `json:"current_open"`
	TotalOpen   int64 `json:"total_open"`
}

type NodeStatsIndicesCompletionResponse

type NodeStatsIndicesCompletionResponse struct {
	SizeInBytes int64 `json:"size_in_bytes"`
}

type NodeStatsIndicesDocsResponse

type NodeStatsIndicesDocsResponse struct {
	Count   int64 `json:"count"`
	Deleted int64 `json:"deleted"`
}

type NodeStatsIndicesFieldDataResponse

type NodeStatsIndicesFieldDataResponse struct {
	MemorySizeInBytes int64 `json:"memory_size_in_bytes"`
	Evictions         int64 `json:"evictions"`
}

type NodeStatsIndicesFilterCacheResponse

type NodeStatsIndicesFilterCacheResponse struct {
	MemorySizeInBytes int64 `json:"memory_size_in_bytes"`
	Evictions         int64 `json:"evictions"`
}

type NodeStatsIndicesFlushResponse

type NodeStatsIndicesFlushResponse struct {
	Total         int64 `json:"total"`
	TotalTimeInMs int64 `json:"total_time_in_millis"`
}

type NodeStatsIndicesGetResponse

type NodeStatsIndicesGetResponse struct {
	Total        int64 `json:"total"`
	Time         int64 `json:"time_in_millis"`
	ExistsTotal  int64 `json:"exists_total"`
	ExistsTime   int64 `json:"exists_time_in_millis"`
	MissingTotal int64 `json:"missing_total"`
	MissingTime  int64 `json:"missing_time_in_millis"`
	Current      int64 `json:"current"`
}

type NodeStatsIndicesIdCacheResponse

type NodeStatsIndicesIdCacheResponse struct {
	MemorySizeInBytes int64 `json:"memory_size_in_bytes"`
}

type NodeStatsIndicesIndexingResponse

type NodeStatsIndicesIndexingResponse struct {
	IndexTotal    int64 `json:"index_total"`
	IndexTime     int64 `json:"index_time_in_millis"`
	IndexCurrent  int64 `json:"index_current"`
	DeleteTotal   int64 `json:"delete_total"`
	DeleteTime    int64 `json:"delete_time_in_millis"`
	DeleteCurrent int64 `json:"delete_current"`
}

type NodeStatsIndicesMergesResponse

type NodeStatsIndicesMergesResponse struct {
	Current            int64 `json:"current"`
	CurrentDocs        int64 `json:"current_docs"`
	CurrentSizeInBytes int64 `json:"current_size_in_bytes"`
	Total              int64 `json:"total"`
	TotalTimeInMs      int64 `json:"total_time_in_millis"`
	TotalDocs          int64 `json:"total_docs"`
	TotalSizeInBytes   int64 `json:"total_size_in_bytes"`
}

type NodeStatsIndicesPercolateResponse

type NodeStatsIndicesPercolateResponse struct {
	Total             int64  `json:"total"`
	TimeInMs          int64  `json:"time_in_millis"`
	Current           int64  `json:"current"`
	MemorySizeInBytes int64  `json:"memory_size_in_bytes"`
	MemorySize        string `json:"memory_size"`
	Queries           int64  `json:"queries"`
}

type NodeStatsIndicesRefreshResponse

type NodeStatsIndicesRefreshResponse struct {
	Total         int64 `json:"total"`
	TotalTimeInMs int64 `json:"total_time_in_millis"`
}

type NodeStatsIndicesResponse

type NodeStatsIndicesResponse struct {
	Docs        NodeStatsIndicesDocsResponse        `json:"docs"`
	Store       NodeStatsIndicesStoreResponse       `json:"store"`
	Indexing    NodeStatsIndicesIndexingResponse    `json:"indexing"`
	Get         NodeStatsIndicesGetResponse         `json:"get"`
	Search      NodeStatsIndicesSearchResponse      `json:"search"`
	Merges      NodeStatsIndicesMergesResponse      `json:"merges"`
	Refresh     NodeStatsIndicesRefreshResponse     `json:"refresh"`
	Flush       NodeStatsIndicesFlushResponse       `json:"flush"`
	Warmer      NodeStatsIndicesWarmerResponse      `json:"warmer"`
	FilterCache NodeStatsIndicesFilterCacheResponse `json:"filter_cache"`
	IdCache     NodeStatsIndicesIdCacheResponse     `json:"id_cache"`
	FieldData   NodeStatsIndicesFieldDataResponse   `json:"fielddata"`
	Percolate   NodeStatsIndicesPercolateResponse   `json:"percolate"`
	Completion  NodeStatsIndicesCompletionResponse  `json:"completion"`
	Segments    NodeStatsIndicesSegmentsResponse    `json:"segments"`
	Translog    NodeStatsIndicesTranslogResponse    `json:"translog"`
	Suggest     NodeStatsIndicesSuggestResponse     `json:"suggest"`
}

type NodeStatsIndicesSearchResponse

type NodeStatsIndicesSearchResponse struct {
	OpenContext  int64 `json:"open_contexts"`
	QueryTotal   int64 `json:"query_total"`
	QueryTime    int64 `json:"query_time_in_millis"`
	QueryCurrent int64 `json:"query_current"`
	FetchTotal   int64 `json:"fetch_total"`
	FetchTime    int64 `json:"fetch_time_in_millis"`
	FetchCurrent int64 `json:"fetch_current"`
}

type NodeStatsIndicesSegmentsResponse

type NodeStatsIndicesSegmentsResponse struct {
	Count                    int64 `json:"count"`
	MemoryInBytes            int64 `json:"memory_in_bytes"`
	IndexWriterMemoryInBytes int64 `json:"index_writer_memory_in_bytes"`
	VersionMapMemoryInBytes  int64 `json:"version_map_memory_in_bytes"`
}

type NodeStatsIndicesStoreResponse

type NodeStatsIndicesStoreResponse struct {
	Size         int64 `json:"size_in_bytes"`
	ThrottleTime int64 `json:"throttle_time_in_millis"`
}

type NodeStatsIndicesSuggestResponse

type NodeStatsIndicesSuggestResponse struct {
	Total    int64 `json:"total"`
	TimeInMs int64 `json:"time_in_millis"`
	Current  int64 `json:"current"`
}

type NodeStatsIndicesTranslogResponse

type NodeStatsIndicesTranslogResponse struct {
	Operations  int64 `json:"operations"`
	SizeInBytes int64 `json:"size_in_bytes"`
}

type NodeStatsIndicesWarmerResponse

type NodeStatsIndicesWarmerResponse struct {
	Current       int64 `json:"current"`
	Total         int64 `json:"total"`
	TotalTimeInMs int64 `json:"total_time_in_millis"`
}

type NodeStatsJVMBufferPoolsResponse

type NodeStatsJVMBufferPoolsResponse struct {
	Count                int64 `json:"count"`
	UsedInBytes          int64 `json:"used_in_bytes"`
	TotalCapacityInBytes int64 `json:"total_capacity_in_bytes"`
}

type NodeStatsJVMGCCollectorsAgeResponse

type NodeStatsJVMGCCollectorsAgeResponse struct {
	Count    int64 `json:"collection_count"`
	TimeInMs int64 `json:"collection_time_in_millis"`
}

type NodeStatsJVMGCResponse

type NodeStatsJVMGCResponse struct {
	Collectors map[string]NodeStatsJVMGCCollectorsAgeResponse `json:"collectors"`
}

type NodeStatsJVMMemPoolsResponse

type NodeStatsJVMMemPoolsResponse struct {
	UsedInBytes     int64 `json:"used_in_bytes"`
	MaxInBytes      int64 `json:"max_in_bytes"`
	PeakUsedInBytes int64 `json:"peak_used_in_bytes"`
	PeakMaxInBytes  int64 `json:"peak_max_in_bytes"`
}

type NodeStatsJVMMemResponse

type NodeStatsJVMMemResponse struct {
	HeapUsedInBytes         int64                                   `json:"heap_used_in_bytes"`
	HeapUsedPercent         int64                                   `json:"heap_used_percent"`
	HeapCommitedInBytes     int64                                   `json:"heap_commited_in_bytes"`
	HeapMaxInBytes          int64                                   `json:"heap_max_in_bytes"`
	NonHeapUsedInBytes      int64                                   `json:"non_heap_used_in_bytes"`
	NonHeapCommittedInBytes int64                                   `json:"non_heap_committed_in_bytes"`
	Pools                   map[string]NodeStatsJVMMemPoolsResponse `json:"pools"`
}

type NodeStatsJVMResponse

type NodeStatsJVMResponse struct {
	Timestame   int64                                      `json:"timestamp"`
	UptimeInMs  int64                                      `json:"uptime_in_millis"`
	Mem         NodeStatsJVMMemResponse                    `json:"mem"`
	Threads     NodeStatsJVMThreadsResponse                `json:"threads"`
	GC          NodeStatsJVMGCResponse                     `json:"gc"`
	BufferPools map[string]NodeStatsJVMBufferPoolsResponse `json:"buffer_pools"`
}

type NodeStatsJVMThreadsResponse

type NodeStatsJVMThreadsResponse struct {
	Count     int64 `json:"count"`
	PeakCount int64 `json:"peak_count"`
}

type NodeStatsNetworkResponse

type NodeStatsNetworkResponse struct {
	TCP NodeStatsTCPResponse `json:"tcp"`
}

type NodeStatsNodeAttributes

type NodeStatsNodeAttributes struct {
	Data   string `json:"data"`
	Client string `json:"client"`
}

type NodeStatsNodeResponse

type NodeStatsNodeResponse struct {
	Name             string                                     `json:"name"`
	Timestamp        int64                                      `json:"timestamp"`
	TransportAddress string                                     `json:"transport_address"`
	Hostname         string                                     `json:"hostname"`
	Host             string                                     `json:"host"`
	IP               []string                                   `json:"ip"`
	Attributes       NodeStatsNodeAttributes                    `json:"attributes"`
	Indices          NodeStatsIndicesResponse                   `json:"indices"`
	OS               NodeStatsOSResponse                        `json:"os"`
	Process          NodeStatsProcessResponse                   `json:"process"`
	JVM              NodeStatsJVMResponse                       `json:"jvm"`
	Network          NodeStatsNetworkResponse                   `json:"network"`
	FS               NodeStatsFSResponse                        `json:"fs"`
	ThreadPool       map[string]NodeStatsThreadPoolPoolResponse `json:"thread_pool"`
	Transport        NodeStatsTransportResponse                 `json:"transport"`
	FieldDataBreaker NodeStatsFieldDataBreakerResponse          `json:"fielddata_breaker"`
}

type NodeStatsOSCPUResponse

type NodeStatsOSCPUResponse struct {
	Sys   int64 `json:"sys"`
	User  int64 `json:"user"`
	Idle  int64 `json:"idle"`
	Steal int64 `json:"stolen"`
}

type NodeStatsOSMemResponse

type NodeStatsOSMemResponse struct {
	Free       int64 `json:"free_in_bytes"`
	Used       int64 `json:"used_in_bytes"`
	ActualFree int64 `json:"actual_free_in_bytes"`
	ActualUsed int64 `json:"actual_used_in_bytes"`
}

type NodeStatsOSResponse

type NodeStatsOSResponse struct {
	Timestamp int64                   `json:"timestamp"`
	Uptime    int64                   `json:"uptime_in_millis"`
	LoadAvg   []float64               `json:"load_average"`
	CPU       NodeStatsOSCPUResponse  `json:"cpu"`
	Mem       NodeStatsOSMemResponse  `json:"mem"`
	Swap      NodeStatsOSSwapResponse `json:"swap"`
}

type NodeStatsOSSwapResponse

type NodeStatsOSSwapResponse struct {
	Used int64 `json:"used_in_bytes"`
	Free int64 `json:"free_in_bytes"`
}

type NodeStatsProcessCPUResponse

type NodeStatsProcessCPUResponse struct {
	Percent int64 `json:"percent"`
	Sys     int64 `json:"sys_in_millis"`
	User    int64 `json:"user_in_millis"`
	Total   int64 `json:"total_in_millis"`
}

type NodeStatsProcessMemResponse

type NodeStatsProcessMemResponse struct {
	Resident     int64 `json:"resident_in_bytes"`
	Share        int64 `json:"share_in_bytes"`
	TotalVirtual int64 `json:"total_virtual_in_bytes"`
}

type NodeStatsProcessResponse

type NodeStatsProcessResponse struct {
	Timestamp int64                       `json:"timestamp"`
	OpenFD    int64                       `json:"open_file_descriptors"`
	CPU       NodeStatsProcessCPUResponse `json:"cpu"`
	Memory    NodeStatsProcessMemResponse `json:"mem"`
}

type NodeStatsResponse

type NodeStatsResponse struct {
	ClusterName string `json:"cluster_name"`
	Nodes       map[string]NodeStatsNodeResponse
}

type NodeStatsTCPResponse

type NodeStatsTCPResponse struct {
	ActiveOpens  int64 `json:"active_opens"`
	PassiveOpens int64 `json:"passive_opens"`
	CurrEstab    int64 `json:"curr_estab"`
	InSegs       int64 `json:"in_segs"`
	OutSegs      int64 `json:"out_segs"`
	RetransSegs  int64 `json:"retrans_segs"`
	EstabResets  int64 `json:"estab_resets"`
	AttemptFails int64 `json:"attempt_fails"`
	InErrs       int64 `json:"in_errs"`
	OutRsts      int64 `json:"out_rsts"`
}

type NodeStatsThreadPoolPoolResponse

type NodeStatsThreadPoolPoolResponse struct {
	Threads   int64 `json:"threads"`
	Queue     int64 `json:"queue"`
	Active    int64 `json:"active"`
	Rejected  int64 `json:"rejected"`
	Largest   int64 `json:"largest"`
	Completed int64 `json:"completed"`
}

type NodeStatsTransportResponse

type NodeStatsTransportResponse struct {
	ServerOpen int64 `json:"server_open"`
	RxCount    int64 `json:"rx_count"`
	RxSize     int64 `json:"rx_size_in_bytes"`
	TxCount    int64 `json:"tx_count"`
	TxSize     int64 `json:"tx_size_in_bytes"`
}

type OS

type OS struct {
	RefreshInterval     int  `json:"refresh_interval,omitempty"`
	AvailableProcessors int  `json:"available_processors,omitempty"`
	CPU                 *CPU `json:"cpu,omitempty"`
}

type OneTermQuery

type OneTermQuery struct {
	Query struct {
		Term string `json:"term"`
	} `json:"query"`
}

type ParentOptions

type ParentOptions struct {
	Type string `json:"type"`
}

type Path

type Path struct {
	Logs string `json:"logs,omitempty"`
	// contains filtered or unexported fields
}

type PercolatorMatch

type PercolatorMatch struct {
	Index string `json:"_index"`
	Id    string `json:"_id"`
}

type PercolatorResult

type PercolatorResult struct {
	SearchResult
	Matches []PercolatorMatch `json:"matches"`
}

type Plugin

type Plugin struct {
	Name        string `json:"name,omitempty"`
	Description string `json:"description,omitempty"`
	Site        bool   `json:"site,omitempty"`
	Jvm         bool   `json:"jvm,omitempty"`
	Url         string `json:"url,omitempty"`
}

type Process

type Process struct {
	RefreshInterval    int  `json:"refresh_interval,omitempty"`
	Id                 int  `json:"id,omitempty"`
	MaxFileDescriptors int  `json:"max_file_descriptors,omitempty"`
	Mlockall           bool `json:"mlockall,omitempty"`
}

type QueryDsl

type QueryDsl struct {
	QueryEmbed
	FilterVal *FilterOp `json:"filter,omitempty"`
}

some ways to serialize

"query": {
	"filtered": {
	  "query": {
	    "query_string": {
	      "default_operator": "OR",
	      "default_field": "_all",
	      "query": " actor:\"bob\"  AND type:\"EventType\""
	    }
	  },
	  "filter": {
	    "range": {
	      "@timestamp": {
	        "from": "2012-12-29T16:52:48+00:00",
	        "to": "2012-12-29T17:52:48+00:00"
	      }
	    }
	  }
	}
},
"query" : {
    "term" : { "user" : "kimchy" }
}
"query" : {
    "match_all" : {}
},

func Query

func Query() *QueryDsl

Query creates a new Query Dsl

func (*QueryDsl) All

func (q *QueryDsl) All() *QueryDsl

get all

func (*QueryDsl) Fields

func (q *QueryDsl) Fields(fields, search, exists, missing string) *QueryDsl

Fields in query_string search

Fields("fieldname","search_for","","")

Fields("fieldname,field2,field3","search_for","","")

Fields("fieldname,field2,field3","search_for","field_exists","")

func (*QueryDsl) Filter

func (q *QueryDsl) Filter(f *FilterOp) *QueryDsl

Filter this query

func (*QueryDsl) FunctionScore

func (q *QueryDsl) FunctionScore(mode string, functions ...map[string]interface{}) *QueryDsl

FunctionScore sets functions to use to score the documents. http://www.elastic.co/guide/en/elasticsearch/reference/1.x/query-dsl-function-score-query.html

func (*QueryDsl) MarshalJSON

func (qd *QueryDsl) MarshalJSON() ([]byte, error)

MarshalJSON provides custom marshalling to support the query dsl which is a conditional json format, not always the same parent/children

func (*QueryDsl) MultiMatch

func (q *QueryDsl) MultiMatch(s string, fields []string) *QueryDsl

MultiMatch allows searching against multiple fields.

func (*QueryDsl) Qs

func (q *QueryDsl) Qs(qs *QueryString) *QueryDsl

Querystring operations

func (*QueryDsl) Range

func (q *QueryDsl) Range(fop *FilterOp) *QueryDsl

Range adds a RANGE FilterOp to the search query Legacy. Use the Filter() function instead

func (*QueryDsl) Search

func (q *QueryDsl) Search(searchFor string) *QueryDsl

The raw search strings (lucene valid)

func (*QueryDsl) SetLenient

func (q *QueryDsl) SetLenient(lenient bool) *QueryDsl

SetLenient sets whether the query should ignore format based failures, such as passing in text to a number field.

func (*QueryDsl) Term

func (q *QueryDsl) Term(name, value string) *QueryDsl

Add a term search for a specific field

Term("user","kimchy")

type QueryEmbed

type QueryEmbed struct {
	MatchAll      *MatchAll              `json:"match_all,omitempty"`
	Terms         map[string]string      `json:"term,omitempty"`
	Qs            *QueryString           `json:"query_string,omitempty"`
	MultiMatch    *MultiMatch            `json:"multi_match,omitempty"`
	FunctionScore map[string]interface{} `json:"function_score,omitempty"`
}

The core Query Syntax can be embedded as a child of a variety of different parents

type QueryString

type QueryString struct {
	DefaultOperator string   `json:"default_operator,omitempty"`
	DefaultField    string   `json:"default_field,omitempty"`
	Query           string   `json:"query,omitempty"`
	Exists          string   `json:"_exists_,omitempty"`
	Missing         string   `json:"_missing_,omitempty"`
	Fields          []string `json:"fields,omitempty"`
	Lenient         bool     `json:"lenient,omitempty"`
}

func NewQueryString

func NewQueryString(field, query string) QueryString

QueryString based search

type QueryWrap

type QueryWrap struct {
	Qs QueryString `json:"query_string,omitempty"`
}

should we reuse QueryDsl here?

type RangeDef

type RangeDef struct {
	Field  string      `json:"field,omitempty"`
	Values []*RangeVal `json:"ranges,omitempty"`
}

type RangeDsl

type RangeDsl struct {
	RangeDef  *RangeDef   `json:"range,omitempty"`
	FilterVal *FilterWrap `json:"facet_filter,omitempty"`
}

func FacetRange

func FacetRange(field string) *RangeDsl

func (*RangeDsl) Filter

func (s *RangeDsl) Filter(fl ...interface{}) *RangeDsl

func (*RangeDsl) Range

func (m *RangeDsl) Range(from, to string) *RangeDsl

type RangeFilter

type RangeFilter struct {
	Gte      interface{} `json:"gte,omitempty"`
	Lte      interface{} `json:"lte,omitempty"`
	Gt       interface{} `json:"gt,omitempty"`
	Lt       interface{} `json:"lt,omitempty"`
	TimeZone string      `json:"time_zone,omitempty"` //Ideally this would be an int
}

RangeFilter filters given a range. Parameters need to be comparable for ES to accept. Only a minimum of one comparison parameter is required. You probably shouldn't mix GT and GTE parameters. Gte: the greater-than-or-equal to value. Should be a number or date. Lte: the less-than-or-equal to value. Should be a number or date. Gt: the greater-than value. Should be a number or date. Lt: the less-than value. Should be a number or date. TimeZone: the timezone to use (+|-h:mm format), if the other parameters are dates

type RangeVal

type RangeVal struct {
	From string `json:"from,omitempty"`
	To   string `json:"to,omitempty"`
}

type Request

type Request struct {
	*http.Client
	*http.Request
	// contains filtered or unexported fields
}

func (*Request) Do

func (r *Request) Do(v interface{}) (int, []byte, error)

func (*Request) DoResponse

func (r *Request) DoResponse(v interface{}) (*http.Response, []byte, error)

func (*Request) SetBody

func (r *Request) SetBody(body io.Reader)

func (*Request) SetBodyBytes

func (r *Request) SetBodyBytes(body []byte)

func (*Request) SetBodyGzip

func (r *Request) SetBodyGzip(data interface{}) error

func (*Request) SetBodyJson

func (r *Request) SetBodyJson(data interface{}) error

func (*Request) SetBodyString

func (r *Request) SetBodyString(body string)

type RoutingOptions

type RoutingOptions struct {
	Required bool   `json:"required,omitempty"`
	Path     string `json:"path,omitempty"`
}

type SWAP

type SWAP struct {
	TotalInBytes int `json:"total_in_bytes,omitempty"`
}

type ScriptFilter

type ScriptFilter struct {
	Script   string                 `json:"script"`
	Params   map[string]interface{} `json:"params,omitempty"`
	IsCached bool                   `json:"_cache,omitempty"`
}

ScriptFilter will filter using a custom javascript function Script: the javascript to run Params: map of custom parameters to pass into the function (JSON), if any IsCached: whether to cache the results of the filter

type SearchDsl

type SearchDsl struct {
	FromVal       int                      `json:"from,omitempty"`
	SizeVal       int                      `json:"size,omitempty"`
	Index         string                   `json:"-"`
	FacetVal      *FacetDsl                `json:"facets,omitempty"`
	QueryVal      *QueryDsl                `json:"query,omitempty"`
	SortBody      []*SortDsl               `json:"sort,omitempty"`
	FilterVal     *FilterOp                `json:"filter,omitempty"`
	AggregatesVal map[string]*AggregateDsl `json:"aggregations,omitempty"`
	HighlightVal  *HighlightDsl            `json:"highlight,omitempty"`
	// contains filtered or unexported fields
}
func Search(index string) *SearchDsl

Search is the entry point to the SearchDsl, it is a chainable set of utilities to create searches.

params

@index = elasticsearch index to search

out, err := Search("github").Type("Issues").Pretty().Query(
Query().Range(
     Range().Field("created_at").From("2012-12-10T15:00:00-08:00").To("2012-12-10T15:10:00-08:00"),
   ).Search("add"),
 ).Result()

func (*SearchDsl) Aggregates

func (s *SearchDsl) Aggregates(aggs ...*AggregateDsl) *SearchDsl

func (*SearchDsl) Bytes

func (s *SearchDsl) Bytes(conn *Conn) ([]byte, error)

func (*SearchDsl) Facet

func (s *SearchDsl) Facet(f *FacetDsl) *SearchDsl

Facet passes a Query expression to this search

qry := Search("github").Size("0").Facet(
			Facet().Regex("repository.name", "no.*").Size("8"),
		)

qry := Search("github").Pretty().Facet(
			Facet().Fields("type").Size("25"),
		)

func (*SearchDsl) Fields

func (s *SearchDsl) Fields(fields ...string) *SearchDsl

func (*SearchDsl) Filter

func (s *SearchDsl) Filter(fl *FilterOp) *SearchDsl

func (*SearchDsl) From

func (s *SearchDsl) From(from string) *SearchDsl

func (*SearchDsl) Highlight

func (s *SearchDsl) Highlight(highlight *HighlightDsl) *SearchDsl

func (*SearchDsl) Pretty

func (s *SearchDsl) Pretty() *SearchDsl

func (*SearchDsl) Query

func (s *SearchDsl) Query(q *QueryDsl) *SearchDsl

func (*SearchDsl) Result

func (s *SearchDsl) Result(conn *Conn) (*SearchResult, error)

func (*SearchDsl) Scroll

func (s *SearchDsl) Scroll(duration string) *SearchDsl

func (*SearchDsl) Search

func (s *SearchDsl) Search(srch string) *SearchDsl

Search is a simple interface to search, doesn't have the power of query but uses a simple query_string search

func (*SearchDsl) SearchType

func (s *SearchDsl) SearchType(searchType string) *SearchDsl

func (*SearchDsl) Size

func (s *SearchDsl) Size(size string) *SearchDsl

func (*SearchDsl) Sort

func (s *SearchDsl) Sort(sort ...*SortDsl) *SearchDsl

func (*SearchDsl) Source

func (s *SearchDsl) Source(returnSource bool) *SearchDsl

func (*SearchDsl) SourceFields

func (s *SearchDsl) SourceFields(fields ...string) *SearchDsl

func (*SearchDsl) Type

func (s *SearchDsl) Type(indexType string) *SearchDsl

Type is the elasticsearch *Type* within a specific index

type SearchRequest

type SearchRequest struct {
	From  int          `json:"from,omitempty"`
	Size  int          `json:"size,omitempty"`
	Query OneTermQuery `json:"query,omitempty"`

	Filter struct {
		Term Term `json:"term"`
	} `json:"filter,omitempty"`
}

type SearchResult

type SearchResult struct {
	RawJSON      []byte
	Took         int             `json:"took"`
	TimedOut     bool            `json:"timed_out"`
	ShardStatus  Status          `json:"_shards"`
	Hits         Hits            `json:"hits"`
	Facets       json.RawMessage `json:"facets,omitempty"` // structure varies on query
	ScrollId     string          `json:"_scroll_id,omitempty"`
	Aggregations json.RawMessage `json:"aggregations,omitempty"` // structure varies on query
	Suggestions  Suggestions     `json:"suggest,omitempty"`
}

func (*SearchResult) String

func (s *SearchResult) String() string

type Settings

type Settings struct {
	Path       *Path  `json:"path,omitempty"`
	Foreground string `json:"foreground,omitempty"`
	Name       string `json:"name,omitempty"`
}

type SizeOptions

type SizeOptions struct {
	Enabled bool `json:"enabled,omitempty"`
	Store   bool `json:"store,omitempty"`
}

type SortBody

type SortBody []interface{}

type SortDsl

type SortDsl struct {
	Name        string
	IsDesc      bool
	GeoDistance interface{}
}

func GeoDistanceSort

func GeoDistanceSort(field interface{}) *SortDsl

func Sort

func Sort(field string) *SortDsl

SortDsl accepts any number of Sort commands

Query().Sort(
    Sort("last_name").Desc(),
    Sort("age"),
)

func (*SortDsl) Asc

func (s *SortDsl) Asc() *SortDsl

func (*SortDsl) Desc

func (s *SortDsl) Desc() *SortDsl

func (*SortDsl) MarshalJSON

func (s *SortDsl) MarshalJSON() ([]byte, error)

type SourceOptions

type SourceOptions struct {
	Enabled  bool     `json:"enabled,omitempty"`
	Includes []string `json:"includes,omitempty"`
	Excludes []string `json:"excludes,omitempty"`
}

type Status

type Status struct {
	Total      StatusInt `json:"total"`
	Successful StatusInt `json:"successful"`
	Failed     StatusInt `json:"failed"`
	Failures   []Failure `json:"failures,omitempty"`
}

type StatusBool

type StatusBool bool

StatusBool is required because /_optimize, at least, returns its status as strings instead of booleans.

func (*StatusBool) MarshalJSON

func (self *StatusBool) MarshalJSON() ([]byte, error)

func (*StatusBool) UnmarshalJSON

func (self *StatusBool) UnmarshalJSON(b []byte) error

type StatusInt

type StatusInt int

StatusInt is required because /_optimize, at least, returns its status as strings instead of integers.

func (*StatusInt) MarshalJSON

func (self *StatusInt) MarshalJSON() ([]byte, error)

func (*StatusInt) UnmarshalJSON

func (self *StatusInt) UnmarshalJSON(b []byte) error

type SuggestResults

type SuggestResults struct {
	ShardStatus Status
	// contains filtered or unexported fields
}

func (SuggestResults) Result

func (s SuggestResults) Result(suggestName string) ([]Suggestion, error)

type Suggestion

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

type SuggestionOption

type SuggestionOption struct {
	Payload json.RawMessage `json:"payload"`
	Score   Float32Nullable `json:"score,omitempty"`
	Text    string          `json:"text"`
}

type Suggestions

type Suggestions map[string][]Suggestion

type TTL

type TTL struct{ time.Time }

TTL is a wrapper around time.Time that converts a number of milliseconds in the future to a time.Time.

func (*TTL) UnmarshalJSON

func (t *TTL) UnmarshalJSON(data []byte) (err error)

type TTLOptions

type TTLOptions struct {
	Enabled bool   `json:"enabled"`
	Default string `json:"default,omitempty"`
}

type Term

type Term struct {
	Terms     Terms       `json:"terms,omitempty"`
	FilterVal *FilterWrap `json:"facet_filter,omitempty"`
}

Generic Term based (used in query, facet, filter)

func NewTerm

func NewTerm(fields ...string) *Term

func (*Term) Filter

func (s *Term) Filter(fl ...interface{}) *Term

type TermExecutionMode

type TermExecutionMode string

TermExecutionMode refers to how a terms (not term) filter should behave The acceptable options are all prefixed with TEM See https://www.elastic.co/guide/en/elasticsearch/reference/1.5/query-dsl-terms-filter.html

const (
	// TEMDefault default ES term filter behavior (plain)
	TEMDefault TermExecutionMode = ""
	// TEMPlain default ES term filter behavior
	TEMPlain TermExecutionMode = "plain"
	// TEMField field_data execution mode
	TEMField TermExecutionMode = "field_data"
	// TEMBool bool execution mode
	TEMBool TermExecutionMode = "bool"
	// TEMAnd and execution mode
	TEMAnd TermExecutionMode = "and"
	// TEMOr or execution mode
	TEMOr TermExecutionMode = "or"
)

type Terms

type Terms struct {
	Fields []string `json:"field,omitempty"`
	Size   string   `json:"size,omitempty"`
	Regex  string   `json:"regex,omitempty"`
}

func (*Terms) MarshalJSON

func (t *Terms) MarshalJSON() ([]byte, error)

Custom marshalling

type ThreadPool

type ThreadPool struct {
	Generic    *ThreadPoolConfig `json:"generic,omitempty"`
	Index      *ThreadPoolConfig `json:"index,omitempty"`
	Get        *ThreadPoolConfig `json:"get,omitempty"`
	Snapshot   *ThreadPoolConfig `json:"snapshot,omitempty"`
	Merge      *ThreadPoolConfig `json:"merge,omitempty"`
	Suggest    *ThreadPoolConfig `json:"suggest,omitempty"`
	Bulk       *ThreadPoolConfig `json:"bulk,omitempty"`
	Optimize   *ThreadPoolConfig `json:"optimize,omitempty"`
	Warmer     *ThreadPoolConfig `json:"warmer,omitempty"`
	Flush      *ThreadPoolConfig `json:"flush,omitempty"`
	Search     *ThreadPoolConfig `json:"search,omitempty"`
	Percolate  *ThreadPoolConfig `json:"percolate,omitempty"`
	Management *ThreadPoolConfig `json:"management,omitempty"`
	Refresh    *ThreadPoolConfig `json:"refresh,omitempty"`
}

type ThreadPoolConfig

type ThreadPoolConfig struct {
	Type      string      `json:"type,omitempty"`
	Min       int         `json:"min,omitempty"`
	Max       int         `json:"max,omitempty"`
	QueueSize interface{} `json:"queue_size,omitempty"` // Either string or -1
	KeepAlive string      `json:"keep_alive,omitempty"`
}

type TimestampOptions

type TimestampOptions struct {
	Enabled bool `json:"enabled"`
}

type Token

type Token struct {
	Name        string `json:"token"`
	StartOffset int    `json:"start_offset"`
	EndOffset   int    `json:"end_offset"`
	Type        string `json:"type"`
	Position    int    `json:"position"`
}

type Transport

type Transport struct {
	BoundAddress   string `json:"bound_address,omitempty"`
	PublishAddress string `json:"publish_address,omitempty"`
}

type TypeFilter

type TypeFilter struct {
	Value string `json:"value"`
}

TypeFilter filters on the document type Value: the document type to filter

type TypeOptions

type TypeOptions struct {
	Store bool   `json:"store,omitempty"`
	Index string `json:"index,omitempty"`
}

type Validation

type Validation struct {
	Valid         bool           `json:"valid"`
	Shards        Status         `json:"_shards"`
	Explainations []Explaination `json:"explanations,omitempty"`
}

Jump to

Keyboard shortcuts

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