Documentation ¶
Index ¶
- Constants
- Variables
- func BoostField(field string, boost float64) string
- func EscapeRegexp(s string) string
- type AndFilter
- type BoostFactorFunction
- type ClusterHealth
- type Database
- func (db *Database) Alias(i, a string) error
- func (db *Database) CreateDocument(index, type_, id string, doc interface{}) error
- func (db *Database) DeleteDocument(index, type_, id string) error
- func (db *Database) DeleteIndex(index string) error
- func (db *Database) GetDocument(index, type_, id string, v interface{}) error
- func (db *Database) GetESDocument(index, type_, id string) (Document, error)
- func (db *Database) HasDocument(index, type_, id string) (bool, error)
- func (db *Database) Health() (ClusterHealth, error)
- func (db *Database) ListAllIndexes() ([]string, error)
- func (db *Database) ListIndexesForAlias(a string) ([]string, error)
- func (db *Database) PostDocument(index, type_ string, doc interface{}) (string, error)
- func (db *Database) PutDocument(index, type_, id string, doc interface{}) error
- func (db *Database) PutDocumentVersion(index, type_, id string, version int64, doc interface{}) error
- func (db *Database) PutDocumentVersionWithType(index, type_, id string, version int64, versionType string, doc interface{}) error
- func (db *Database) PutIndex(index string, config interface{}) error
- func (db *Database) PutMapping(index, type_ string, config interface{}) error
- func (db *Database) RefreshIndex(index string) error
- func (db *Database) Search(index, type_ string, q QueryDSL) (SearchResult, error)
- type DecayFunction
- type Document
- type ElasticSearchError
- type ExistsFilter
- type FieldValueFactorFunction
- type Fields
- type Filter
- type FilteredQuery
- type Function
- type FunctionScoreQuery
- type Hit
- type MatchAllQuery
- type MatchQuery
- type MultiMatchQuery
- type NotFilter
- type OrFilter
- type Order
- type Query
- type QueryDSL
- type QueryFilter
- type RegexpFilter
- type SearchResult
- type Sort
- type TermFilter
- type TermQuery
Constants ¶
const ( // Internal provides elasticsearche's "internal" versioning system, as described in // http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/docs-index_.html#_version_types Internal = "internal" // External provides elasticsearche's "external" versioning system, as described in // http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/docs-index_.html#_version_types External = "external" // ExternalGTE provides elasticsearche's "external_gte" versioning system, as described in // http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/docs-index_.html#_version_types ExternalGTE = "external_gte" )
Variables ¶
var Ascending = Order{"asc"}
Ascending is an Order that orders a sort by ascending through the values.
var Descending = Order{"desc"}
Descending is an Order that orders a sort by descending throuth the values.
var ErrConflict = errgo.New("elasticsearch document conflict")
var ErrNotFound = errgo.New("elasticsearch document not found")
Functions ¶
func BoostField ¶
BoostField creates a string which represents a field name with a boost value.
func EscapeRegexp ¶
EscapeRegexp returns the supplied string with any special characters escaped. A regular expression match on the returned string will match exactly the characters in the supplied string.
Types ¶
type AndFilter ¶
type AndFilter []Filter
AndFilter provides a filter that matches if all of the internal filters match.
func (AndFilter) MarshalJSON ¶
type BoostFactorFunction ¶
type BoostFactorFunction struct { Filter Filter `json:"filter,omitempty"` BoostFactor float64 `json:"boost_factor"` }
BoostFactorFunction provides a function that boosts results by the specified amount.
type ClusterHealth ¶
type ClusterHealth struct { ClusterName string `json:"cluster_name"` Status string `json:"status"` TimedOut bool `json:"timed_out"` NumberOfNodes int64 `json:"number_of_nodes"` NumberOfDataNodes int64 `json:"number_of_data_nodes"` ActivePrimaryShards int64 `json:"active_primary_shards"` ActiveShards int64 `json:"active_shards"` RelocatingShards int64 `json:"relocating_shards"` InitializingShards int64 `json:"initializing_shards"` UnassignedShards int64 `json:"unassigned_shards"` }
Represents the response from _cluster/health on elastic search http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/cluster-health.html
func (*ClusterHealth) String ¶
func (h *ClusterHealth) String() string
type Database ¶
type Database struct {
Addr string
}
func (*Database) Alias ¶
Alias creates or updates an index alias. An alias a is created, or modified if it already exists, to point to i. See http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-aliases.html#indices-aliases for further details.
func (*Database) CreateDocument ¶
Create document attempts to create a new document at index/type_/id with the contents in doc. If the document already exists then CreateDocument will return ErrConflict and return a non-nil error if any other error occurs. See http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/create-doc.html#create-doc for further details.
func (*Database) DeleteDocument ¶
DeleteDocument deletes the document at index/type_/id from the elasticsearch database. See http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/delete-doc.html#delete-doc for further details.
func (*Database) DeleteIndex ¶
DeleteIndex deletes the index with the given name from the database. http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-delete-index.html If the index does not exist or if the database cannot be reached, then an error is returned.
func (*Database) GetDocument ¶
GetDocument retrieves the document with the given index, type_ and id and unmarshals the json response into v. GetDocument returns ErrNotFound if the requested document is not present, and returns a non-nil error if any other error occurs.
func (*Database) GetESDocument ¶
GetESDocument returns elasticsearch's view of the document stored at index/type_/id. It is not an error if this document does not exist, in that case the Found field of the returned Document will be false.
func (*Database) HasDocument ¶
HasDocument tests to see a document of the given index, type_, and id exists in the elasticsearch database. A non-nil error is returned if there is an error communicating with the elasticsearch database.
func (*Database) Health ¶
func (db *Database) Health() (ClusterHealth, error)
Check the health status of Elastic search and retrieve general data from it. Calling get on /_cluster/health to retrieve status.
func (*Database) ListAllIndexes ¶
ListAllIndexes retreieves the list of all user indexes in the elasticsearch database. indexes that are generated to to support plugins are filtered out of the list that is returned.
func (*Database) ListIndexesForAlias ¶
ListIndexesForAlias retreieves the list of all indexes in the elasticsearch database that have the alias a.
func (*Database) PostDocument ¶
PostDocument creates a new auto id document with the given index and _type and returns the generated id of the document. The type_ parameter controls how the document will be mapped in the index. See http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/docs-index_.html for more details.
func (*Database) PutDocument ¶
PutDocument creates or updates the document with the given index, type_ and id. The type_ parameter controls how the document will be mapped in the index. See http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/docs-index_.html for more details.
func (*Database) PutDocumentVersion ¶
func (db *Database) PutDocumentVersion(index, type_, id string, version int64, doc interface{}) error
PutDocumentVersion creates or updates the document in the given index if the version parameter is the same as the currently stored version. The type_ parameter controls how the document will be indexed. PutDocumentVersion returns ErrConflict if the data cannot be stored due to a version mismatch, and a non-nil error if any other error occurs. See http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/docs-index_.html#index-versioning for more information.
func (*Database) PutDocumentVersionWithType ¶
func (db *Database) PutDocumentVersionWithType( index, type_, id string, version int64, versionType string, doc interface{}) error
PutDocumentVersion creates or updates the document in the given index if the version parameter is the same as the currently stored version. The type_ parameter controls how the document will be indexed. PutDocumentVersionWithType returns ErrConflict if the data cannot be stored due to a version mismatch, and a non-nil error if any other error occurs.
The constants Internal, External and ExternalGTE represent some of the available version types. Other version types may also be available, plese check the elasticsearch documentation.
See http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/docs-index_.html#index-versioning and http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/docs-index_.html#_version_types for more information.
func (*Database) PutMapping ¶
PutMapping creates or updates the mapping with the given configuration.
func (*Database) RefreshIndex ¶
RefreshIndex posts a _refresh to the index in the database. http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-refresh.html
type DecayFunction ¶
DecayFunction provides a function that boosts depending on the difference in values of a certain field. See http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html#_decay_functions for details.
func (DecayFunction) MarshalJSON ¶
func (f DecayFunction) MarshalJSON() ([]byte, error)
type Document ¶
type Document struct { Found bool `json:"found"` Id string `json:"_id"` Index string `json:"_index"` Type string `json:"_type"` Version int64 `json:"_version"` Source json.RawMessage `json:"_source"` }
Document represents a document in the elasticsearch database.
type ElasticSearchError ¶
func (ElasticSearchError) Error ¶
func (e ElasticSearchError) Error() string
type ExistsFilter ¶
type ExistsFilter string
ExistsFilter provides a filter that requres a field to be present.
func (ExistsFilter) MarshalJSON ¶
func (f ExistsFilter) MarshalJSON() ([]byte, error)
type FieldValueFactorFunction ¶
type FieldValueFactorFunction struct { Field string `json:"field"` Factor float64 `json:"factor,omitempty"` Modifier string `json:"modifier,omitempty"` }
FieldValueFactorFunction boosts the results by the value of a field in the document.
func (FieldValueFactorFunction) MarshalJSON ¶
func (f FieldValueFactorFunction) MarshalJSON() ([]byte, error)
type Fields ¶
type Fields map[string][]interface{}
type FilteredQuery ¶
FilteredQuery provides a query that includes a filter.
func (FilteredQuery) MarshalJSON ¶
func (f FilteredQuery) MarshalJSON() ([]byte, error)
type Function ¶
type Function interface{}
Function is a function definition for use with a FunctionScoreQuery.
type FunctionScoreQuery ¶
FunctionScoreQuery provides a query that adjusts the scoring of a query by applying functions to it.
func (FunctionScoreQuery) MarshalJSON ¶
func (f FunctionScoreQuery) MarshalJSON() ([]byte, error)
type Hit ¶
type Hit struct { Index string `json:"_index"` Type string `json:"_type"` ID string `json:"_id"` Score float64 `json:"_score"` Source json.RawMessage `json:"_source"` Fields Fields `json:"fields"` }
Hit represents an individual search hit returned from elasticsearch
type MatchAllQuery ¶
type MatchAllQuery struct { }
MatchAllQuery provides a query that matches all documents in the index.
func (MatchAllQuery) MarshalJSON ¶
func (m MatchAllQuery) MarshalJSON() ([]byte, error)
type MatchQuery ¶
MatchQuery provides a query that matches against a complete field.
func (MatchQuery) MarshalJSON ¶
func (m MatchQuery) MarshalJSON() ([]byte, error)
type MultiMatchQuery ¶
type MultiMatchQuery struct { Query string Fields []string // MinimumShouldMatch optionally contains the value for the // minimum_should_match parameter, For details of possible values // please see: // https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-minimum-should-match.html MinimumShouldMatch string }
MultiMatchQuery provides a query that matches on a number of fields.
func (MultiMatchQuery) MarshalJSON ¶
func (m MultiMatchQuery) MarshalJSON() ([]byte, error)
type NotFilter ¶
type NotFilter struct {
Filter Filter
}
NotFilter provides a filter that matches the opposite of the wrapped filter.
func (NotFilter) MarshalJSON ¶
type OrFilter ¶
type OrFilter []Filter
OrFilter provides a filter that matches if any of the internal filters match.
func (OrFilter) MarshalJSON ¶
type QueryDSL ¶
type QueryDSL struct { Fields []string `json:"fields"` From int `json:"from,omitempty"` Size int `json:"size,omitempty"` Query Query `json:"query,omitempty"` Sort []Sort `json:"sort,omitempty"` }
QueryDSL provides a structure to put together a query using the elasticsearch DSL.
type QueryFilter ¶
type QueryFilter struct {
Query Query
}
QueryFilter provides a filter that matches when a query matches on a result
func (QueryFilter) MarshalJSON ¶
func (q QueryFilter) MarshalJSON() ([]byte, error)
type RegexpFilter ¶
RegexpFilter provides a filter that matches a field against a regular expression.
func (RegexpFilter) MarshalJSON ¶
func (r RegexpFilter) MarshalJSON() ([]byte, error)
type SearchResult ¶
type SearchResult struct { Hits struct { Total int `json:"total"` MaxScore float64 `json:"max_score"` Hits []Hit `json:"hits"` } `json:"hits"` Took int `json:"took"` TimedOut bool `json:"timed_out"` }
SearchResult is the result returned after performing a search in elasticsearch
type Sort ¶
func (Sort) MarshalJSON ¶
type TermFilter ¶
TermFilter provides a filter that requires a field to match.
func (TermFilter) MarshalJSON ¶
func (t TermFilter) MarshalJSON() ([]byte, error)