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 ¶
- Constants
- Variables
- func Escape(args map[string]interface{}) (s string, err error)
- func GetIndexUrl(index string, _type string, id string, parentId string, version int, ...) (retval string, e error)
- func ScrollDuration(duration string) string
- func WriteBulkBytes(op string, index string, _type string, id, parent, ttl string, date *time.Time, ...) ([]byte, error)
- type AggregateDsl
- func (d *AggregateDsl) Aggregates(aggs ...*AggregateDsl) *AggregateDsl
- func (d *AggregateDsl) Avg(field string) *AggregateDsl
- func (d *AggregateDsl) Cardinality(field string, rehash bool, threshold int) *AggregateDsl
- func (d *AggregateDsl) DateHistogram(field, interval string) *AggregateDsl
- func (d *AggregateDsl) ExtendedStats(field string) *AggregateDsl
- func (d *AggregateDsl) Filter(filters ...interface{}) *AggregateDsl
- func (d *AggregateDsl) Global() *AggregateDsl
- func (d *AggregateDsl) Histogram(field string, interval int) *AggregateDsl
- func (d *AggregateDsl) MarshalJSON() ([]byte, error)
- func (d *AggregateDsl) Max(field string) *AggregateDsl
- func (d *AggregateDsl) Min(field string) *AggregateDsl
- func (d *AggregateDsl) Missing(field string) *AggregateDsl
- func (d *AggregateDsl) Percentiles(field string) *AggregateDsl
- func (d *AggregateDsl) SignificantTerms(field string) *AggregateDsl
- func (d *AggregateDsl) Stats(field string) *AggregateDsl
- func (d *AggregateDsl) Sum(field string) *AggregateDsl
- func (d *AggregateDsl) Terms(field string) *AggregateDsl
- func (d *AggregateDsl) TermsWithSize(field string, size int) *AggregateDsl
- func (d *AggregateDsl) ValueCount(field string) *AggregateDsl
- type AllocateCommand
- type AnalyzeResponse
- type AnalyzerOptions
- type BaseResponse
- type BoolClause
- type BulkIndexer
- func (b *BulkIndexer) Delete(index, _type, id string)
- func (b *BulkIndexer) Flush()
- func (b *BulkIndexer) Index(index string, _type string, id, parent, ttl string, date *time.Time, ...) error
- func (b *BulkIndexer) NumErrors() uint64
- func (b *BulkIndexer) PendingDocuments() int
- func (b *BulkIndexer) Send(buf *bytes.Buffer) error
- func (b *BulkIndexer) Start()
- func (b *BulkIndexer) Stop()
- func (b *BulkIndexer) Update(index string, _type string, id, parent, ttl string, date *time.Time, ...) error
- func (b *BulkIndexer) UpdateWithPartialDoc(index string, _type string, id, parent, ttl string, date *time.Time, ...) error
- func (b *BulkIndexer) UpdateWithWithScript(index string, _type string, id, parent, ttl string, date *time.Time, ...) error
- type CPU
- type CancelCommand
- type Cardinality
- type CatAliasInfo
- type CatIndexDocs
- type CatIndexInfo
- type CatIndexStore
- type CatNodeInfo
- type CatShardInfo
- type CatShards
- type Cluster
- type ClusterHealthResponse
- type ClusterSettingsResponse
- type ClusterStateFilter
- type ClusterStateIndiceResponse
- type ClusterStateMetadataResponse
- type ClusterStateNodeResponse
- type ClusterStateResponse
- type ClusterStateRoutingTableResponse
- type Commands
- type Conn
- func (c *Conn) AddAlias(index string, alias string) (BaseResponse, error)
- func (c *Conn) AllNodesInfo() (NodeInfo, error)
- func (c *Conn) AnalyzeIndices(index string, args map[string]interface{}) (AnalyzeResponse, error)
- func (c *Conn) ClearCache(clearId bool, clearBloom bool, args map[string]interface{}, indices ...string) (ExtendedStatus, error)
- func (c *Conn) Close()
- func (c *Conn) CloseIndex(index string) (BaseResponse, error)
- func (c *Conn) CloseIndices() (BaseResponse, error)
- func (c *Conn) ClusterState(filter ClusterStateFilter) (ClusterStateResponse, error)
- func (c *Conn) Count(index string, _type string, args map[string]interface{}, query interface{}) (CountResponse, error)
- func (c *Conn) CreateIndex(index string) (BaseResponse, error)
- func (c *Conn) CreateIndexWithSettings(index string, settings interface{}) (BaseResponse, error)
- func (c *Conn) CreateSnapshotRepository(name string, args map[string]interface{}, settings interface{}) (BaseResponse, error)
- func (c *Conn) Delete(index string, _type string, id string, args map[string]interface{}) (BaseResponse, error)
- func (c *Conn) DeleteByQuery(indices []string, types []string, args map[string]interface{}, ...) (BaseResponse, error)
- func (c *Conn) DeleteIndex(index string) (BaseResponse, error)
- func (c *Conn) DeleteMapping(index string, typeName string) (BaseResponse, error)
- func (c *Conn) DoCommand(method string, url string, args map[string]interface{}, data interface{}) ([]byte, error)
- func (c *Conn) Exists(index string, _type string, id string, args map[string]interface{}) (BaseResponse, error)
- func (c *Conn) ExistsBool(index string, _type string, id string, args map[string]interface{}) (bool, error)
- func (c *Conn) ExistsIndex(index string, _type string, args map[string]interface{}) (bool, error)
- func (c *Conn) Explain(index string, _type string, id string, args map[string]interface{}, ...) (Match, error)
- func (c *Conn) Flush(indices ...string) (BaseResponse, error)
- func (c *Conn) Get(index string, _type string, id string, args map[string]interface{}) (BaseResponse, error)
- func (c *Conn) GetCatAliasInfo(pattern string) (catAliases []CatAliasInfo)
- func (c *Conn) GetCatIndexInfo(pattern string) (catIndices []CatIndexInfo)
- func (c *Conn) GetCatNodeInfo(fields []string) (catNodes []CatNodeInfo, err error)
- func (c *Conn) GetCatShards() (shards CatShards)
- func (c *Conn) GetCustom(index string, _type string, id string, args map[string]interface{}, ...) (BaseResponse, error)
- func (c *Conn) GetSnapshotByName(repository, name string, args map[string]interface{}) (GetSnapshotsResponse, error)
- func (c *Conn) GetSnapshots(repository string, args map[string]interface{}) (GetSnapshotsResponse, error)
- func (c *Conn) GetSource(index string, _type string, id string, args map[string]interface{}, ...) error
- func (c *Conn) Health(indices ...string) (ClusterHealthResponse, error)
- func (c *Conn) Index(index string, _type string, id string, args map[string]interface{}, ...) (BaseResponse, error)
- func (c *Conn) IndexWithParameters(index string, _type string, id string, parentId string, version int, ...) (BaseResponse, error)
- func (c *Conn) IndicesExists(indices ...string) (bool, error)
- func (c *Conn) MGet(index string, _type string, mgetRequest MGetRequestContainer, ...) (MGetResponseContainer, error)
- func (c *Conn) MoreLikeThis(index string, _type string, id string, args map[string]interface{}, ...) (BaseResponse, error)
- func (c *Conn) NewBulkIndexer(maxConns int) *BulkIndexer
- func (c *Conn) NewBulkIndexerErrors(maxConns, retrySeconds int) *BulkIndexer
- func (c *Conn) NewRequest(method, path, query string) (*Request, error)
- func (c *Conn) NodesInfo(information []string, nodes ...string) (NodeInfo, error)
- func (c *Conn) NodesShutdown(delay int, nodes ...string) error
- func (c *Conn) NodesStats() (NodeStatsResponse, error)
- func (c *Conn) OpenIndex(index string) (BaseResponse, error)
- func (c *Conn) OpenIndices() (BaseResponse, error)
- func (c *Conn) OptimizeIndices(args map[string]interface{}, indices ...string) (ExtendedStatus, error)
- func (c *Conn) Percolate(index string, _type string, name string, args map[string]interface{}, ...) (PercolatorResult, error)
- func (c *Conn) PutMapping(index string, typeName string, instance interface{}, opt MappingOptions) error
- func (c *Conn) PutMappingFromJSON(index string, typeName string, mapping []byte) error
- func (c *Conn) PutSettings(index string, settings interface{}) (BaseResponse, error)
- func (c *Conn) Refresh(indices ...string) (BaseResponse, error)
- func (c *Conn) RegisterPercolate(index string, id string, data interface{}) (BaseResponse, error)
- func (c *Conn) Reroute(dryRun bool, commands Commands) (ClusterHealthResponse, error)
- func (c *Conn) RestoreSnapshot(repository, name string, args map[string]interface{}, query interface{}) (BaseResponse, error)
- func (c *Conn) Scroll(args map[string]interface{}, scroll_id string) (SearchResult, error)
- func (c *Conn) Search(index string, _type string, args map[string]interface{}, query interface{}) (SearchResult, error)
- func (c *Conn) SearchUri(index, _type string, args map[string]interface{}) (SearchResult, error)
- func (c *Conn) SetFromUrl(u string) error
- func (c *Conn) SetHosts(newhosts []string)
- func (c *Conn) SetPort(port string)
- func (c *Conn) Snapshot(indices ...string) (ExtendedStatus, error)
- func (c *Conn) Status(args map[string]interface{}, indices ...string) (BaseResponse, error)
- func (c *Conn) Suggest(index string, args map[string]interface{}, query interface{}) (SuggestResults, error)
- func (c *Conn) TakeSnapshot(repository, name string, args map[string]interface{}, query interface{}) (BaseResponse, error)
- func (c *Conn) Update(index string, _type string, id string, args map[string]interface{}, ...) (BaseResponse, error)
- func (c *Conn) UpdateSetting(args map[string]interface{}, filter_indices ...string) (ClusterStateResponse, error)
- func (c *Conn) UpdateSettings(settingType string, key string, value int) (ClusterSettingsResponse, error)
- func (c *Conn) UpdateWithPartialDoc(index string, _type string, id string, args map[string]interface{}, ...) (BaseResponse, error)
- func (c *Conn) UpdateWithScript(index string, _type string, id string, args map[string]interface{}, ...) (BaseResponse, error)
- func (c *Conn) Validate(index string, _type string, args map[string]interface{}) (BaseResponse, error)
- func (c *Conn) WaitForStatus(status string, timeout int, indices ...string) (ClusterHealthResponse, error)
- type CountResponse
- type DateHistogram
- type DeleteByQueryResponse
- type ESError
- type ErrorBuffer
- type Explaination
- type Explanation
- type ExtendedStatus
- type FacetDsl
- type Facets
- type Failure
- type FieldAggregate
- type FilterClause
- type FilterOp
- func (f *FilterOp) And(filters ...*FilterOp) *FilterOp
- func (f *FilterOp) Exists(field string) *FilterOp
- func (f *FilterOp) GeoDistance(distance string, fields ...GeoField) *FilterOp
- func (f *FilterOp) GeoDistanceRange(from string, to string, fields ...GeoField) *FilterOp
- func (f *FilterOp) Ids(ids ...interface{}) *FilterOp
- func (f *FilterOp) IdsByTypes(types []string, ids ...interface{}) *FilterOp
- func (f *FilterOp) Limit(maxResults int) *FilterOp
- func (f *FilterOp) Missing(field string) *FilterOp
- func (f *FilterOp) Not(filters ...*FilterOp) *FilterOp
- func (f *FilterOp) Or(filters ...*FilterOp) *FilterOp
- func (f *FilterOp) Range(field string, gte interface{}, gt interface{}, lte interface{}, lt interface{}, ...) *FilterOp
- func (f *FilterOp) Term(field string, value interface{}) *FilterOp
- func (f *FilterOp) Terms(field string, executionMode TermExecutionMode, values ...interface{}) *FilterOp
- func (f *FilterOp) Type(fieldType string) *FilterOp
- type FilterWrap
- type Float32Nullable
- type GeoField
- type GeoLocation
- type GetSnapshotsResponse
- type Highlight
- type HighlightDsl
- type HighlightEmbed
- func (o *HighlightEmbed) BoundaryChars(chars string) *HighlightEmbed
- func (o *HighlightEmbed) BoundaryMaxScan(max int) *HighlightEmbed
- func (he *HighlightEmbed) FragSize(size int) *HighlightEmbed
- func (he *HighlightEmbed) MatchedFields(fields ...string) *HighlightEmbed
- func (he *HighlightEmbed) NumFrags(numFrags int) *HighlightEmbed
- func (he *HighlightEmbed) Order(order string) *HighlightEmbed
- func (he *HighlightEmbed) Tags(pre string, post string) *HighlightEmbed
- func (he *HighlightEmbed) Type(highlightType string) *HighlightEmbed
- type Histogram
- type Hit
- type Hits
- type Http
- type IdOptions
- type IdsFilter
- type IndexStatus
- type Interface
- type JVM
- type JsonAlias
- type JsonAliasAdd
- type JsonAliases
- type JvmMem
- type LimitFilter
- type MEM
- type MGetRequest
- type MGetRequestContainer
- type MGetResponseContainer
- type MLT
- type Mapping
- type MappingOptions
- type Match
- type MatchAll
- type MatchRes
- type MoreLikeThisQuery
- type MoveCommand
- type MultiMatch
- type Network
- type Node
- type NodeInfo
- type NodeStatsFSDataResponse
- type NodeStatsFSResponse
- type NodeStatsFieldDataBreakerResponse
- type NodeStatsHTTPResponse
- type NodeStatsIndicesCompletionResponse
- type NodeStatsIndicesDocsResponse
- type NodeStatsIndicesFieldDataResponse
- type NodeStatsIndicesFilterCacheResponse
- type NodeStatsIndicesFlushResponse
- type NodeStatsIndicesGetResponse
- type NodeStatsIndicesIdCacheResponse
- type NodeStatsIndicesIndexingResponse
- type NodeStatsIndicesMergesResponse
- type NodeStatsIndicesPercolateResponse
- type NodeStatsIndicesRefreshResponse
- type NodeStatsIndicesResponse
- type NodeStatsIndicesSearchResponse
- type NodeStatsIndicesSegmentsResponse
- type NodeStatsIndicesStoreResponse
- type NodeStatsIndicesSuggestResponse
- type NodeStatsIndicesTranslogResponse
- type NodeStatsIndicesWarmerResponse
- type NodeStatsJVMBufferPoolsResponse
- type NodeStatsJVMGCCollectorsAgeResponse
- type NodeStatsJVMGCResponse
- type NodeStatsJVMMemPoolsResponse
- type NodeStatsJVMMemResponse
- type NodeStatsJVMResponse
- type NodeStatsJVMThreadsResponse
- type NodeStatsNetworkResponse
- type NodeStatsNodeAttributes
- type NodeStatsNodeResponse
- type NodeStatsOSCPUResponse
- type NodeStatsOSMemResponse
- type NodeStatsOSResponse
- type NodeStatsOSSwapResponse
- type NodeStatsProcessCPUResponse
- type NodeStatsProcessMemResponse
- type NodeStatsProcessResponse
- type NodeStatsResponse
- type NodeStatsTCPResponse
- type NodeStatsThreadPoolPoolResponse
- type NodeStatsTransportResponse
- type OS
- type OneTermQuery
- type ParentOptions
- type Path
- type PercolatorMatch
- type PercolatorResult
- type Plugin
- type Process
- type QueryDsl
- func (q *QueryDsl) All() *QueryDsl
- func (q *QueryDsl) Fields(fields, search, exists, missing string) *QueryDsl
- func (q *QueryDsl) Filter(f *FilterOp) *QueryDsl
- func (q *QueryDsl) FunctionScore(mode string, functions ...map[string]interface{}) *QueryDsl
- func (qd *QueryDsl) MarshalJSON() ([]byte, error)
- func (q *QueryDsl) MultiMatch(s string, fields []string) *QueryDsl
- func (q *QueryDsl) Qs(qs *QueryString) *QueryDsl
- func (q *QueryDsl) Range(fop *FilterOp) *QueryDsl
- func (q *QueryDsl) Search(searchFor string) *QueryDsl
- func (q *QueryDsl) SetLenient(lenient bool) *QueryDsl
- func (q *QueryDsl) Term(name, value string) *QueryDsl
- type QueryEmbed
- type QueryString
- type QueryWrap
- type RangeDef
- type RangeDsl
- type RangeFilter
- type RangeVal
- type Request
- func (r *Request) Do(v interface{}) (int, []byte, error)
- func (r *Request) DoResponse(v interface{}) (*http.Response, []byte, error)
- func (r *Request) SetBody(body io.Reader)
- func (r *Request) SetBodyBytes(body []byte)
- func (r *Request) SetBodyGzip(data interface{}) error
- func (r *Request) SetBodyJson(data interface{}) error
- func (r *Request) SetBodyString(body string)
- type RoutingOptions
- type SWAP
- type ScriptFilter
- type SearchDsl
- func (s *SearchDsl) Aggregates(aggs ...*AggregateDsl) *SearchDsl
- func (s *SearchDsl) Bytes(conn *Conn) ([]byte, error)
- func (s *SearchDsl) Facet(f *FacetDsl) *SearchDsl
- func (s *SearchDsl) Fields(fields ...string) *SearchDsl
- func (s *SearchDsl) Filter(fl *FilterOp) *SearchDsl
- func (s *SearchDsl) From(from string) *SearchDsl
- func (s *SearchDsl) Highlight(highlight *HighlightDsl) *SearchDsl
- func (s *SearchDsl) Pretty() *SearchDsl
- func (s *SearchDsl) Query(q *QueryDsl) *SearchDsl
- func (s *SearchDsl) Result(conn *Conn) (*SearchResult, error)
- func (s *SearchDsl) Scroll(duration string) *SearchDsl
- func (s *SearchDsl) Search(srch string) *SearchDsl
- func (s *SearchDsl) SearchType(searchType string) *SearchDsl
- func (s *SearchDsl) Size(size string) *SearchDsl
- func (s *SearchDsl) Sort(sort ...*SortDsl) *SearchDsl
- func (s *SearchDsl) Source(returnSource bool) *SearchDsl
- func (s *SearchDsl) SourceFields(fields ...string) *SearchDsl
- func (s *SearchDsl) Type(indexType string) *SearchDsl
- type SearchRequest
- type SearchResult
- type Settings
- type SizeOptions
- type SortBody
- type SortDsl
- type SourceOptions
- type Status
- type StatusBool
- type StatusInt
- type SuggestResults
- type Suggestion
- type SuggestionOption
- type Suggestions
- type TTL
- type TTLOptions
- type Term
- type TermExecutionMode
- type Terms
- type ThreadPool
- type ThreadPoolConfig
- type TimestampOptions
- type Token
- type Transport
- type TypeFilter
- type TypeOptions
- type Validation
Examples ¶
Constants ¶
const ( Version = "0.0.2" DefaultProtocol = "http" DefaultDomain = "localhost" DefaultPort = "9200" // A decay duration of zero results in the default behaviour DefaultDecayDuration = 0 )
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 ¶
var ErrInvalidAliasLine = errors.New("Cannot parse aliasline")
var ErrInvalidIndexLine = errors.New("Cannot parse indexline")
var ErrInvalidShardLine = errors.New("Cannot parse shardline")
var RecordNotFound = errors.New("record not found")
404 Response.
Functions ¶
func GetIndexUrl ¶
func ScrollDuration ¶
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 AnalyzeResponse ¶
type AnalyzeResponse struct {
Tokens []Token `json:"tokens"`
}
type AnalyzerOptions ¶
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) UpdateWithPartialDoc ¶
func (*BulkIndexer) UpdateWithWithScript ¶
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 Cardinality ¶
type CatAliasInfo ¶
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 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 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
type CatShards ¶
type CatShards []CatShardInfo
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 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 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 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 (*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 ¶
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) 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) 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 ¶
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 ¶
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 ¶
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) NodesShutdown ¶
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) 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) PutMapping ¶
func (c *Conn) PutMapping(index string, typeName string, instance interface{}, opt MappingOptions) error
func (*Conn) PutMappingFromJSON ¶
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 (*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 ¶
type CountResponse ¶
type DateHistogram ¶
type DeleteByQueryResponse ¶
type DeleteByQueryResponse struct { Status bool `json:"ok"` Indicies map[string]IndexStatus `json:"_indices"` }
type ErrorBuffer ¶
type Explaination ¶
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) MarshalJSON ¶
type Failure ¶
type FieldAggregate ¶
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 ¶
And will add an AND op to the filter. One or more FilterOps can be passed in.
func (*FilterOp) GeoDistance ¶
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 ¶
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) IdsByTypes ¶
IdsByTypes adds a IDS op to the filter, but also allows passing in an array of types for the query.
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 ¶
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.
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 (*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.
type GeoLocation ¶
GeoLocation holds the coordinates for a geo query. Currently hashes are not supported.
type GetSnapshotsResponse ¶
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 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 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 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 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 MGetRequest ¶
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 MoreLikeThisQuery ¶
type MoreLikeThisQuery struct {
MoreLikeThis MLT `json:"more_like_this"`
}
type MoveCommand ¶
type MultiMatch ¶
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 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 NodeStatsIndicesCompletionResponse ¶
type NodeStatsIndicesCompletionResponse struct {
SizeInBytes int64 `json:"size_in_bytes"`
}
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 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 NodeStatsJVMGCResponse ¶
type NodeStatsJVMGCResponse struct {
Collectors map[string]NodeStatsJVMGCCollectorsAgeResponse `json:"collectors"`
}
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 NodeStatsNetworkResponse ¶
type NodeStatsNetworkResponse struct {
TCP NodeStatsTCPResponse `json:"tcp"`
}
type NodeStatsNodeAttributes ¶
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 NodeStatsOSMemResponse ¶
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 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 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 PercolatorResult ¶
type PercolatorResult struct { SearchResult Matches []PercolatorMatch `json:"matches"` }
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 (*QueryDsl) Fields ¶
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) FunctionScore ¶
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 ¶
MarshalJSON provides custom marshalling to support the query dsl which is a conditional json format, not always the same parent/children
func (*QueryDsl) MultiMatch ¶
MultiMatch allows searching against multiple fields.
func (*QueryDsl) Range ¶
Range adds a RANGE FilterOp to the search query Legacy. Use the Filter() function instead
func (*QueryDsl) SetLenient ¶
SetLenient sets whether the query should ignore format based failures, such as passing in text to a number field.
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"` }
type QueryWrap ¶
type QueryWrap struct {
Qs QueryString `json:"query_string,omitempty"`
}
should we reuse QueryDsl here?
type RangeDsl ¶
type RangeDsl struct { RangeDef *RangeDef `json:"range,omitempty"` FilterVal *FilterWrap `json:"facet_filter,omitempty"` }
func FacetRange ¶
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 Request ¶
func (*Request) DoResponse ¶
func (*Request) SetBodyBytes ¶
func (*Request) SetBodyGzip ¶
func (*Request) SetBodyJson ¶
func (*Request) SetBodyString ¶
type RoutingOptions ¶
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 ¶
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) Facet ¶
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) Highlight ¶
func (s *SearchDsl) Highlight(highlight *HighlightDsl) *SearchDsl
func (*SearchDsl) Search ¶
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 (*SearchDsl) SourceFields ¶
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 SizeOptions ¶
type SortDsl ¶
func GeoDistanceSort ¶
func GeoDistanceSort(field interface{}) *SortDsl
func Sort ¶
SortDsl accepts any number of Sort commands
Query().Sort( Sort("last_name").Desc(), Sort("age"), )
func (*SortDsl) MarshalJSON ¶
type SourceOptions ¶
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 (*StatusInt) UnmarshalJSON ¶
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 ¶
TTL is a wrapper around time.Time that converts a number of milliseconds in the future to a time.Time.
func (*TTL) UnmarshalJSON ¶
type TTLOptions ¶
type Term ¶
type Term struct { Terms Terms `json:"terms,omitempty"` FilterVal *FilterWrap `json:"facet_filter,omitempty"` }
Generic Term based (used in query, facet, filter)
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 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 TimestampOptions ¶
type TimestampOptions struct {
Enabled bool `json:"enabled"`
}
type TypeFilter ¶
type TypeFilter struct {
Value string `json:"value"`
}
TypeFilter filters on the document type Value: the document type to filter
type TypeOptions ¶
type Validation ¶
type Validation struct { Valid bool `json:"valid"` Shards Status `json:"_shards"` Explainations []Explaination `json:"explanations,omitempty"` }
Source Files ¶
- baserequest.go
- baseresponse.go
- cataliasinfo.go
- catindexinfo.go
- catnodeinfo.go
- catresponses.go
- catshardinfo.go
- clusterhealth.go
- clusterhealthresponses.go
- clusternodeshotthreads.go
- clusternodesinfo.go
- clusternodesshutdown.go
- clusternodesstats.go
- clusterreroute.go
- clusterstate.go
- clusterstatresponses.go
- clusterupdatesettings.go
- connection.go
- corebulk.go
- corebulkudp.go
- corecount.go
- coredelete.go
- coredeletebyquery.go
- coreexplain.go
- coreget.go
- coreindex.go
- coremget.go
- coremorelikethis.go
- coremsearch.go
- corepercolate.go
- coresearch.go
- coreupdate.go
- corevalidate.go
- error.go
- indicesaliases.go
- indicesanalyze.go
- indicesclearcache.go
- indicescreateindex.go
- indicesdeleteindex.go
- indicesdeletemapping.go
- indicesdoc.go
- indicesflush.go
- indicesgetsettings.go
- indicesindicesexists.go
- indicesopencloseindex.go
- indicesoptimize.go
- indicesputmapping.go
- indicesputsettings.go
- indicesrefresh.go
- indicessegments.go
- indicessnapshot.go
- indicesstats.go
- indicesstatus.go
- indicestemplates.go
- indicesupdatesettings.go
- request.go
- searchaggregate.go
- searchdsl.go
- searchfacet.go
- searchfilter.go
- searchhighlight.go
- searchquery.go
- searchsearch.go
- searchsort.go
- shared.go
- snapshot.go