Documentation ¶
Index ¶
- func BoostField(field string, boost float64) string
- func EscapeRegexp(s string) string
- type AndFilter
- type BoostFactorFunction
- type Database
- func (db *Database) DeleteIndex(index string) error
- func (db *Database) EnsureID(index, type_, id string) (bool, error)
- func (db *Database) GetDocument(index, type_, id string, v interface{}) error
- func (db *Database) Index(name string) *Index
- func (db *Database) ListAllIndexes() ([]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{}) (bool, 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 ElasticSearchError
- type Fields
- type Filter
- type FilteredQuery
- type Function
- type FunctionScoreQuery
- type Hit
- type Index
- func (i *Index) Delete() error
- func (i *Index) GetDocument(type_, id string, doc interface{}) error
- func (i *Index) PutDocument(type_, id string, doc interface{}) error
- func (i *Index) PutDocumentVersion(type_, id string, version int64, doc interface{}) (bool, error)
- func (i *Index) Search(type_ string, q QueryDSL) (SearchResult, error)
- 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 ¶
This section is empty.
Variables ¶
This section is empty.
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 Database ¶
type Database struct {
Addr string
}
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) EnsureID ¶
EnsureID tests to see a document of the given index, type_, and id exists in ElasticSearch.
func (*Database) GetDocument ¶
GetDocument retrieves the document with the given index, type_ and id and unmarshals the json response into v.
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) 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{}) (bool, error)
PutDocumentVersion creates or updates the document with the given index if the version is equal or newer than the currently stored version. The type_ parameter controls how the document will be indexed. PutDocumentVersion returns a bool indicating if the data was stored and an error. If the data was not stored due to a version conflict the returned value will be false, nil. See http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/docs-index_.html#index-versioning 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 ElasticSearchError ¶
func (ElasticSearchError) Error ¶
func (e ElasticSearchError) Error() string
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 Index ¶
Index represents an index in the elasticsearch database.
func (*Index) GetDocument ¶
GetDocument retrieves the document with the given type_ and id in the index. This is a wrapper around Database.GetDocument.
func (*Index) PutDocument ¶
PutDocument creates or updates the document with the given type_ and id in the index. This is a wrapper around Database.PutDocument.
func (*Index) PutDocumentVersion ¶
PutDocumentVersion creates or updates the document with the given type_ and id in the index if the version is the same or newer than the currently store version. This is a wrapper around Database.PutDocumentVersion.
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 ¶
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)