Documentation
¶
Index ¶
- Variables
- func BulkIndexorRun(maxConns int, done chan bool)
- func BulkSend(buf *bytes.Buffer)
- func Delete(pretty bool, index string, _type string, id string, version int, ...) (api.BaseResponse, error)
- func DeleteByQuery(pretty bool, indices []string, types []string, query interface{}) (api.BaseResponse, error)
- func Exists(pretty bool, index string, _type string, id string) (api.BaseResponse, error)
- func Explain(pretty bool, index string, _type string, id string, query string) (api.Match, error)
- func Get(pretty bool, index string, _type string, id string) (api.BaseResponse, error)
- func Index(pretty bool, index string, _type string, id string, data interface{}) (api.BaseResponse, error)
- func IndexBulk(index string, _type string, id string, date *time.Time, data interface{}) error
- func MoreLikeThis(pretty bool, index string, _type string, id string, query MoreLikeThisQuery) (api.BaseResponse, error)
- func Percolate(pretty bool, index string, _type string, name string, doc string) (api.Match, error)
- func RegisterPercolate(pretty bool, index string, name string, query api.Query) (api.BaseResponse, error)
- func Update(pretty bool, index string, _type string, id string) (api.BaseResponse, error)
- func Validate(pretty bool, index string, _type string, query string, explain bool) (api.BaseResponse, error)
- type BulkIndexor
- type CountResponse
- type DeleteByQueryResponse
- type Explaination
- type Hit
- type Hits
- type IndexStatus
- type MGetRequest
- type MGetRequestContainer
- type MGetResponseContainer
- type MLT
- type MoreLikeThisQuery
- type SearchResult
- type Validation
Constants ¶
This section is empty.
Variables ¶
var ( // Max buffer size in bytes before flushing to elasticsearch BulkMaxBuffer = 1048576 // Max number of Docs to hold in buffer before forcing flush BulkMaxDocs = 100 // Max delay before forcing a flush to Elasticearch BulkDelaySeconds = 5 // Keep a running total of errors seen, since it is in the background BulkErrorCt uint64 // We are creating a variable defining the func responsible for sending // to allow a mock sendor for test purposes BulkSendor func(*bytes.Buffer) )
var (
DebugRequests = false
)
Functions ¶
func BulkIndexorRun ¶
Start up goroutines, channels to start buffering and sending bulk index operations The send is a callback incase you want to do a special send, or otherwise see/count etc Args
@maxConns is the max number of in flight http requests @done is a channel to cause the indexor to stop done := make(chan bool) BulkIndexorRun(100, done)
func BulkSend ¶
This does the actual send of a buffer, which has already been formatted into bytes of ES formatted bulk data
func Delete ¶
func Delete(pretty bool, index string, _type string, id string, version int, routing string) (api.BaseResponse, error)
The 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 todo: add routing and versioning support
func DeleteByQuery ¶
func DeleteByQuery(pretty bool, indices []string, types []string, query interface{}) (api.BaseResponse, error)
The delete by query API allows 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 Exists ¶
The API also allows to check for the existance of a document using HEAD This appears to be broken in the current version of elasticsearch 0.19.10, currently returning nothing
func Explain ¶
The explain api 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 Get ¶
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 Index ¶
func Index(pretty bool, index string, _type string, id string, data interface{}) (api.BaseResponse, error)
The index API adds or updates a typed JSON document in a specific index, making it searchable. http://www.elasticsearch.org/guide/reference/api/index_.html
func IndexBulk ¶
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 MoreLikeThis ¶
func MoreLikeThis(pretty bool, index string, _type string, id string, query MoreLikeThisQuery) (api.BaseResponse, error)
The more like this (mlt) API allows to get documents that are “like” a specified document. http://www.elasticsearch.org/guide/reference/api/more-like-this.html
func RegisterPercolate ¶
func RegisterPercolate(pretty bool, index string, name string, query api.Query) (api.BaseResponse, error)
The percolator allows to register queries against an index, and then send percolate requests which include a doc, and getting back the queries that match on that doc out of the set of registered queries. Think of it as the reverse operation of indexing and then searching. Instead of sending docs, indexing them, and then running queries. One sends queries, registers them, and then sends docs and finds out which queries match that doc. see http://www.elasticsearch.org/guide/reference/api/percolate.html
func Update ¶
The update API allows to update 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
Types ¶
type BulkIndexor ¶
type BulkIndexor struct {
// contains filtered or unexported fields
}
func NewBulkIndexor ¶
func NewBulkIndexor(maxConns int) *BulkIndexor
type CountResponse ¶
func Count ¶
func Count(pretty bool, index string, _type string) (CountResponse, error)
The count API allows 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 TODO: take parameters. currently not working against 0.19.10
type DeleteByQueryResponse ¶
type DeleteByQueryResponse struct {
Status bool `json:"ok"`
Indicies map[string]IndexStatus `json:"_indices"`
}
type Explaination ¶
type Hits ¶
type IndexStatus ¶
type MGetRequest ¶
type MGetRequestContainer ¶
type MGetRequestContainer struct {
Docs []MGetRequest `json:"docs"`
}
type MGetResponseContainer ¶
type MGetResponseContainer struct {
Docs []api.BaseResponse `json:"docs"`
}
func MGet ¶
func MGet(pretty bool, index string, _type string, mgetRequest MGetRequestContainer) (MGetResponseContainer, error)
Multi GET API allows 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
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 MoreLikeThisQuery ¶
type MoreLikeThisQuery struct {
MoreLikeThis MLT `json:"more_like_this"`
}
type SearchResult ¶
type SearchResult struct {
Took int `json:"took"`
TimedOut bool `json:"timed_out"`
ShardStatus api.Status `json:"_shards"`
Hits Hits `json:"hits"`
Facets json.RawMessage `json:"facets,omitempty"` // structure varies on query
ScrollId string `json:"_scroll_id,omitempty"`
}
func SearchRequest ¶
func SearchRequest(pretty bool, index string, _type string, query interface{}, scroll string) (SearchResult, error)
Performs a very basic search on an index via the request URI API.
params:
@pretty: bool for pretty reply or not, a parameter to elasticsearch
@index: the elasticsearch index
@_type: optional ("" if not used) search specific type in this index
@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 := SearchRequest(true, "github","",qryType ,"")
http://www.elasticsearch.org/guide/reference/api/search/uri-request.html
func SearchUri ¶
func SearchUri(index, _type string, query, scroll string) (SearchResult, error)
Performs the simplest possible query in url string params:
@index: the elasticsearch index
@_type: optional ("" if not used) search specific type in this index
@query: valid string lucene search syntax
out, err := SearchUri("github","",`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 (*SearchResult) String ¶
func (s *SearchResult) String() string
type Validation ¶
type Validation struct {
Valid bool `json:"valid"`
Shards api.Status `json:"_shards"`
Explainations []Explaination `json:"explanations,omitempty"`
}