elastic.v2: gopkg.in/olivere/elastic.v2 Index | Examples | Files | Directories

package elastic

import "gopkg.in/olivere/elastic.v2"

Package elastic provides an interface to the Elasticsearch server (http://www.elasticsearch.org/).

The first thing you do is to create a Client. If you have Elasticsearch installed and running with its default settings (i.e. available at http://127.0.0.1:9200), all you need to do is:

client, err := elastic.NewClient()
if err != nil {
	// Handle error
}

If your Elasticsearch server is running on a different IP and/or port, just provide a URL to NewClient:

// Create a client and connect to http://192.168.2.10:9201
client, err := elastic.NewClient(elastic.SetURL("http://192.168.2.10:9201"))
if err != nil {
  // Handle error
}

You can pass many more configuration parameters to NewClient. Review the documentation of NewClient for more information.

If no Elasticsearch server is available, services will fail when creating a new request and will return ErrNoClient.

A Client provides services. The services usually come with a variety of methods to prepare the query and a Do function to execute it against the Elasticsearch REST interface and return a response. Here is an example of the IndexExists service that checks if a given index already exists.

exists, err := client.IndexExists("twitter").Do()
if err != nil {
	// Handle error
}
if !exists {
	// Index does not exist yet.
}

Look up the documentation for Client to get an idea of the services provided and what kinds of responses you get when executing the Do function of a service. Also see the wiki on Github for more details.

Code:

errorlog := log.New(os.Stdout, "APP ", log.LstdFlags)

// Obtain a client. You can provide your own HTTP client here.
client, err := elastic.NewClient(elastic.SetErrorLog(errorlog))
if err != nil {
    // Handle error
    panic(err)
}

// Trace request and response details like this
//client.SetTracer(log.New(os.Stdout, "", 0))

// Ping the Elasticsearch server to get e.g. the version number
info, code, err := client.Ping().Do()
if err != nil {
    // Handle error
    panic(err)
}
fmt.Printf("Elasticsearch returned with code %d and version %s", code, info.Version.Number)

// Getting the ES version number is quite common, so there's a shortcut
esversion, err := client.ElasticsearchVersion("http://127.0.0.1:9200")
if err != nil {
    // Handle error
    panic(err)
}
fmt.Printf("Elasticsearch version %s", esversion)

// Use the IndexExists service to check if a specified index exists.
exists, err := client.IndexExists("twitter").Do()
if err != nil {
    // Handle error
    panic(err)
}
if !exists {
    // Create a new index.
    createIndex, err := client.CreateIndex("twitter").Do()
    if err != nil {
        // Handle error
        panic(err)
    }
    if !createIndex.Acknowledged {
        // Not acknowledged
    }
}

// Index a tweet (using JSON serialization)
tweet1 := Tweet{User: "olivere", Message: "Take Five", Retweets: 0}
put1, err := client.Index().
    Index("twitter").
    Type("tweet").
    Id("1").
    BodyJson(tweet1).
    Do()
if err != nil {
    // Handle error
    panic(err)
}
fmt.Printf("Indexed tweet %s to index %s, type %s\n", put1.Id, put1.Index, put1.Type)

// Index a second tweet (by string)
tweet2 := `{"user" : "olivere", "message" : "It's a Raggy Waltz"}`
put2, err := client.Index().
    Index("twitter").
    Type("tweet").
    Id("2").
    BodyString(tweet2).
    Do()
if err != nil {
    // Handle error
    panic(err)
}
fmt.Printf("Indexed tweet %s to index %s, type %s\n", put2.Id, put2.Index, put2.Type)

// Get tweet with specified ID
get1, err := client.Get().
    Index("twitter").
    Type("tweet").
    Id("1").
    Do()
if err != nil {
    // Handle error
    panic(err)
}
if get1.Found {
    fmt.Printf("Got document %s in version %d from index %s, type %s\n", get1.Id, get1.Version, get1.Index, get1.Type)
}

// Flush to make sure the documents got written.
_, err = client.Flush().Index("twitter").Do()
if err != nil {
    panic(err)
}

// Search with a term query
termQuery := elastic.NewTermQuery("user", "olivere")
searchResult, err := client.Search().
    Index("twitter").   // search in index "twitter"
    Query(&termQuery).  // specify the query
    Sort("user", true). // sort by "user" field, ascending
    From(0).Size(10).   // take documents 0-9
    Pretty(true).       // pretty print request and response JSON
    Do()                // execute
if err != nil {
    // Handle error
    panic(err)
}

// searchResult is of type SearchResult and returns hits, suggestions,
// and all kinds of other information from Elasticsearch.
fmt.Printf("Query took %d milliseconds\n", searchResult.TookInMillis)

// Each is a convenience function that iterates over hits in a search result.
// It makes sure you don't need to check for nil values in the response.
// However, it ignores errors in serialization. If you want full control
// over iterating the hits, see below.
var ttyp Tweet
for _, item := range searchResult.Each(reflect.TypeOf(ttyp)) {
    t := item.(Tweet)
    fmt.Printf("Tweet by %s: %s\n", t.User, t.Message)
}
// TotalHits is another convenience function that works even when something goes wrong.
fmt.Printf("Found a total of %d tweets\n", searchResult.TotalHits())

// Here's how you iterate through results with full control over each step.
if searchResult.Hits.TotalHits > 0 {
    fmt.Printf("Found a total of %d tweets\n", searchResult.Hits.TotalHits)

    // Iterate through results
    for _, hit := range searchResult.Hits.Hits {
        // hit.Index contains the name of the index

        // Deserialize hit.Source into a Tweet (could also be just a map[string]interface{}).
        var t Tweet
        err := json.Unmarshal(*hit.Source, &t)
        if err != nil {
            // Deserialization failed
        }

        // Work with tweet
        fmt.Printf("Tweet by %s: %s\n", t.User, t.Message)
    }
} else {
    // No hits
    fmt.Print("Found no tweets\n")
}

// Update a tweet by the update API of Elasticsearch.
// We just increment the number of retweets.
update, err := client.Update().Index("twitter").Type("tweet").Id("1").
    Script("ctx._source.retweets += num").
    ScriptParams(map[string]interface{}{"num": 1}).
    Upsert(map[string]interface{}{"retweets": 0}).
    Do()
if err != nil {
    // Handle error
    panic(err)
}
fmt.Printf("New version of tweet %q is now %d", update.Id, update.Version)

// ...

// Delete an index.
deleteIndex, err := client.DeleteIndex("twitter").Do()
if err != nil {
    // Handle error
    panic(err)
}
if !deleteIndex.Acknowledged {
    // Not acknowledged
}

Index

Examples

Package Files

alias.go aliases.go bulk.go bulk_delete_request.go bulk_index_request.go bulk_processor.go bulk_request.go bulk_update_request.go canonicalize.go clear_scroll.go client.go cluster_health.go cluster_state.go cluster_stats.go connection.go count.go create_index.go decoder.go delete.go delete_by_query.go delete_index.go delete_mapping.go delete_template.go doc.go errors.go exists.go explain.go fetch_source_context.go field_stats.go filter.go flush.go geo_point.go get.go get_mapping.go get_template.go highlight.go index.go index_close.go index_exists.go index_get.go index_open.go indices_delete_template.go indices_delete_warmer.go indices_exists_template.go indices_exists_type.go indices_get_settings.go indices_get_template.go indices_get_warmer.go indices_put_settings.go indices_put_template.go indices_put_warmer.go indices_stats.go inner_hit.go logger.go mtermvectors.go multi_get.go multi_search.go nodes_info.go nodes_stats.go optimize.go percolate.go ping.go put_mapping.go put_template.go query.go refresh.go reindexer.go request.go rescore.go rescorer.go response.go scan.go scroll.go search.go search_aggs.go search_aggs_avg.go search_aggs_cardinality.go search_aggs_children.go search_aggs_date_histogram.go search_aggs_date_range.go search_aggs_extended_stats.go search_aggs_filter.go search_aggs_filters.go search_aggs_geo_bounds.go search_aggs_geo_distance.go search_aggs_geohash_grid.go search_aggs_global.go search_aggs_histogram.go search_aggs_max.go search_aggs_min.go search_aggs_missing.go search_aggs_nested.go search_aggs_percentile_ranks.go search_aggs_percentiles.go search_aggs_range.go search_aggs_reverse_nested.go search_aggs_significant_terms.go search_aggs_stats.go search_aggs_sum.go search_aggs_terms.go search_aggs_tophits.go search_aggs_value_count.go search_facets.go search_facets_date_histogram.go search_facets_filter.go search_facets_geo_distance.go search_facets_histogram.go search_facets_histogram_script.go search_facets_query.go search_facets_range.go search_facets_statistical.go search_facets_statistical_script.go search_facets_terms.go search_facets_terms_stats.go search_filters_and.go search_filters_bool.go search_filters_exists.go search_filters_geo_distance.go search_filters_geo_polygon.go search_filters_has_child.go search_filters_has_parent.go search_filters_ids.go search_filters_limit.go search_filters_match_all.go search_filters_missing.go search_filters_nested.go search_filters_not.go search_filters_or.go search_filters_prefix.go search_filters_query.go search_filters_range.go search_filters_regexp.go search_filters_term.go search_filters_terms.go search_filters_type.go search_queries_bool.go search_queries_boosting.go search_queries_common.go search_queries_constant_score.go search_queries_custom_filters_score.go search_queries_custom_score.go search_queries_dis_max.go search_queries_filtered.go search_queries_fsq.go search_queries_fsq_score_funcs.go search_queries_fuzzy.go search_queries_fuzzy_like_this.go search_queries_fuzzy_like_this_field_query.go search_queries_has_child.go search_queries_has_parent.go search_queries_ids.go search_queries_match.go search_queries_match_all.go search_queries_more_like_this.go search_queries_more_like_this_field.go search_queries_multi_match.go search_queries_nested.go search_queries_prefix.go search_queries_query_string.go search_queries_range.go search_queries_raw_string.go search_queries_regexp.go search_queries_simple_query_string.go search_queries_template_query.go search_queries_term.go search_queries_terms.go search_queries_wildcard.go search_request.go search_source.go sort.go suggest.go suggest_field.go suggester.go suggester_completion.go suggester_completion_fuzzy.go suggester_context.go suggester_context_category.go suggester_context_geo.go suggester_phrase.go suggester_term.go termvector.go update.go

Constants

const (
    // Version is the current version of Elastic.
    Version = "2.0.57"

    // DefaultUrl is the default endpoint of Elasticsearch on the local machine.
    // It is used e.g. when initializing a new Client without a specific URL.
    DefaultURL = "http://127.0.0.1:9200"

    // DefaultScheme is the default protocol scheme to use when sniffing
    // the Elasticsearch cluster.
    DefaultScheme = "http"

    // DefaultHealthcheckEnabled specifies if healthchecks are enabled by default.
    DefaultHealthcheckEnabled = true

    // DefaultHealthcheckTimeoutStartup is the time the healthcheck waits
    // for a response from Elasticsearch on startup, i.e. when creating a
    // client. After the client is started, a shorter timeout is commonly used
    // (its default is specified in DefaultHealthcheckTimeout).
    DefaultHealthcheckTimeoutStartup = 5 * time.Second

    // DefaultHealthcheckTimeout specifies the time a running client waits for
    // a response from Elasticsearch. Notice that the healthcheck timeout
    // when a client is created is larger by default (see DefaultHealthcheckTimeoutStartup).
    DefaultHealthcheckTimeout = 1 * time.Second

    // DefaultHealthcheckInterval is the default interval between
    // two health checks of the nodes in the cluster.
    DefaultHealthcheckInterval = 60 * time.Second

    // DefaultSnifferEnabled specifies if the sniffer is enabled by default.
    DefaultSnifferEnabled = true

    // DefaultSnifferInterval is the interval between two sniffing procedures,
    // i.e. the lookup of all nodes in the cluster and their addition/removal
    // from the list of actual connections.
    DefaultSnifferInterval = 15 * time.Minute

    // DefaultSnifferTimeoutStartup is the default timeout for the sniffing
    // process that is initiated while creating a new client. For subsequent
    // sniffing processes, DefaultSnifferTimeout is used (by default).
    DefaultSnifferTimeoutStartup = 5 * time.Second

    // DefaultSnifferTimeout is the default timeout after which the
    // sniffing process times out. Notice that for the initial sniffing
    // process, DefaultSnifferTimeoutStartup is used.
    DefaultSnifferTimeout = 2 * time.Second

    // DefaultMaxRetries is the number of retries for a single request after
    // Elastic will give up and return an error. It is zero by default, so
    // retry is disabled by default.
    DefaultMaxRetries = 0

    // DefaultSendGetBodyAs is the HTTP method to use when elastic is sending
    // a GET request with a body.
    DefaultSendGetBodyAs = "GET"

    // DefaultGzipEnabled specifies if gzip compression is enabled by default.
    DefaultGzipEnabled = false
)
const (
    FieldStatsClusterLevel = "cluster"
    FieldStatsIndicesLevel = "indices"
)

Variables

var (
    // ErrNoClient is raised when no Elasticsearch node is available.
    ErrNoClient = errors.New("no Elasticsearch node available")

    // ErrRetry is raised when a request cannot be executed after the configured
    // number of retries.
    ErrRetry = errors.New("cannot connect after several retries")

    // ErrTimeout is raised when a request timed out, e.g. when WaitForStatus
    // didn't return in time.
    ErrTimeout = errors.New("timeout")
)
var (
    // ErrMissingIndex is returned e.g. from DeleteService if the index is missing.
    ErrMissingIndex = errors.New("elastic: index is missing")

    // ErrMissingType is returned e.g. from DeleteService if the type is missing.
    ErrMissingType = errors.New("elastic: type is missing")

    // ErrMissingId is returned e.g. from DeleteService if the document identifier is missing.
    ErrMissingId = errors.New("elastic: id is missing")
)
var (
    // End of stream (or scan)
    EOS = errors.New("EOS")

    // No ScrollId
    ErrNoScrollId = errors.New("no scrollId")
)

type Aggregation Uses

type Aggregation interface {
    Source() interface{}
}

Aggregations can be seen as a unit-of-work that build analytic information over a set of documents. It is (in many senses) the follow-up of facets in Elasticsearch. For more details about aggregations, visit: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations.html

type AggregationBucketFilters Uses

type AggregationBucketFilters struct {
    Aggregations

    Buckets      []*AggregationBucketKeyItem          //`json:"buckets"`
    NamedBuckets map[string]*AggregationBucketKeyItem //`json:"buckets"`
}

AggregationBucketFilters is a multi-bucket aggregation that is returned with a filters aggregation.

func (*AggregationBucketFilters) UnmarshalJSON Uses

func (a *AggregationBucketFilters) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes JSON data and initializes an AggregationBucketFilters structure.

type AggregationBucketHistogramItem Uses

type AggregationBucketHistogramItem struct {
    Aggregations

    Key         int64   //`json:"key"`
    KeyAsString *string //`json:"key_as_string"`
    DocCount    int64   //`json:"doc_count"`
}

AggregationBucketHistogramItem is a single bucket of an AggregationBucketHistogramItems structure.

func (*AggregationBucketHistogramItem) UnmarshalJSON Uses

func (a *AggregationBucketHistogramItem) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes JSON data and initializes an AggregationBucketHistogramItem structure.

type AggregationBucketHistogramItems Uses

type AggregationBucketHistogramItems struct {
    Aggregations

    Buckets []*AggregationBucketHistogramItem //`json:"buckets"`
}

AggregationBucketHistogramItems is a bucket aggregation that is returned with a date histogram aggregation.

func (*AggregationBucketHistogramItems) UnmarshalJSON Uses

func (a *AggregationBucketHistogramItems) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes JSON data and initializes an AggregationBucketHistogramItems structure.

type AggregationBucketKeyItem Uses

type AggregationBucketKeyItem struct {
    Aggregations

    Key         interface{} //`json:"key"`
    KeyAsString *string     //`json:"key_as_string"`
    KeyNumber   json.Number
    DocCount    int64 //`json:"doc_count"`
}

AggregationBucketKeyItem is a single bucket of an AggregationBucketKeyItems structure.

func (*AggregationBucketKeyItem) UnmarshalJSON Uses

func (a *AggregationBucketKeyItem) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes JSON data and initializes an AggregationBucketKeyItem structure.

type AggregationBucketKeyItems Uses

type AggregationBucketKeyItems struct {
    Aggregations

    DocCountErrorUpperBound int64                       //`json:"doc_count_error_upper_bound"`
    SumOfOtherDocCount      int64                       //`json:"sum_other_doc_count"`
    Buckets                 []*AggregationBucketKeyItem //`json:"buckets"`
}

AggregationBucketKeyItems is a bucket aggregation that is e.g. returned with a terms aggregation.

func (*AggregationBucketKeyItems) UnmarshalJSON Uses

func (a *AggregationBucketKeyItems) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes JSON data and initializes an AggregationBucketKeyItems structure.

type AggregationBucketKeyedRangeItems Uses

type AggregationBucketKeyedRangeItems struct {
    Aggregations

    DocCountErrorUpperBound int64                                  //`json:"doc_count_error_upper_bound"`
    SumOfOtherDocCount      int64                                  //`json:"sum_other_doc_count"`
    Buckets                 map[string]*AggregationBucketRangeItem //`json:"buckets"`
}

AggregationBucketKeyedRangeItems is a bucket aggregation that is e.g. returned with a keyed range aggregation.

func (*AggregationBucketKeyedRangeItems) UnmarshalJSON Uses

func (a *AggregationBucketKeyedRangeItems) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes JSON data and initializes an AggregationBucketRangeItems structure.

type AggregationBucketRangeItem Uses

type AggregationBucketRangeItem struct {
    Aggregations

    Key          string   //`json:"key"`
    DocCount     int64    //`json:"doc_count"`
    From         *float64 //`json:"from"`
    FromAsString string   //`json:"from_as_string"`
    To           *float64 //`json:"to"`
    ToAsString   string   //`json:"to_as_string"`
}

AggregationBucketRangeItem is a single bucket of an AggregationBucketRangeItems structure.

func (*AggregationBucketRangeItem) UnmarshalJSON Uses

func (a *AggregationBucketRangeItem) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes JSON data and initializes an AggregationBucketRangeItem structure.

type AggregationBucketRangeItems Uses

type AggregationBucketRangeItems struct {
    Aggregations

    DocCountErrorUpperBound int64                         //`json:"doc_count_error_upper_bound"`
    SumOfOtherDocCount      int64                         //`json:"sum_other_doc_count"`
    Buckets                 []*AggregationBucketRangeItem //`json:"buckets"`
}

AggregationBucketRangeItems is a bucket aggregation that is e.g. returned with a range aggregation.

func (*AggregationBucketRangeItems) UnmarshalJSON Uses

func (a *AggregationBucketRangeItems) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes JSON data and initializes an AggregationBucketRangeItems structure.

type AggregationBucketSignificantTerm Uses

type AggregationBucketSignificantTerm struct {
    Aggregations

    Key      string  //`json:"key"`
    DocCount int64   //`json:"doc_count"`
    BgCount  int64   //`json:"bg_count"`
    Score    float64 //`json:"score"`
}

AggregationBucketSignificantTerm is a single bucket of an AggregationBucketSignificantTerms structure.

func (*AggregationBucketSignificantTerm) UnmarshalJSON Uses

func (a *AggregationBucketSignificantTerm) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes JSON data and initializes an AggregationBucketSignificantTerm structure.

type AggregationBucketSignificantTerms Uses

type AggregationBucketSignificantTerms struct {
    Aggregations

    DocCount int64                               //`json:"doc_count"`
    Buckets  []*AggregationBucketSignificantTerm //`json:"buckets"`
}

AggregationBucketSignificantTerms is a bucket aggregation returned with a significant terms aggregation.

func (*AggregationBucketSignificantTerms) UnmarshalJSON Uses

func (a *AggregationBucketSignificantTerms) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes JSON data and initializes an AggregationBucketSignificantTerms structure.

type AggregationExtendedStatsMetric Uses

type AggregationExtendedStatsMetric struct {
    Aggregations

    Count        int64    // `json:"count"`
    Min          *float64 //`json:"min,omitempty"`
    Max          *float64 //`json:"max,omitempty"`
    Avg          *float64 //`json:"avg,omitempty"`
    Sum          *float64 //`json:"sum,omitempty"`
    SumOfSquares *float64 //`json:"sum_of_squares,omitempty"`
    Variance     *float64 //`json:"variance,omitempty"`
    StdDeviation *float64 //`json:"std_deviation,omitempty"`
}

AggregationExtendedStatsMetric is a multi-value metric, returned by an ExtendedStats aggregation.

func (*AggregationExtendedStatsMetric) UnmarshalJSON Uses

func (a *AggregationExtendedStatsMetric) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes JSON data and initializes an AggregationExtendedStatsMetric structure.

type AggregationGeoBoundsMetric Uses

type AggregationGeoBoundsMetric struct {
    Aggregations

    Bounds struct {
        TopLeft struct {
            Latitude  float64 `json:"lat"`
            Longitude float64 `json:"lon"`
        }   `json:"top_left"`
        BottomRight struct {
            Latitude  float64 `json:"lat"`
            Longitude float64 `json:"lon"`
        }   `json:"bottom_right"`
    }   `json:"bounds"`
}

AggregationGeoBoundsMetric is a metric as returned by a GeoBounds aggregation.

func (*AggregationGeoBoundsMetric) UnmarshalJSON Uses

func (a *AggregationGeoBoundsMetric) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes JSON data and initializes an AggregationGeoBoundsMetric structure.

type AggregationPercentilesMetric Uses

type AggregationPercentilesMetric struct {
    Aggregations

    Values map[string]float64 // `json:"values"`
}

AggregationPercentilesMetric is a multi-value metric, returned by a Percentiles aggregation.

func (*AggregationPercentilesMetric) UnmarshalJSON Uses

func (a *AggregationPercentilesMetric) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes JSON data and initializes an AggregationPercentilesMetric structure.

type AggregationSingleBucket Uses

type AggregationSingleBucket struct {
    Aggregations

    DocCount int64 // `json:"doc_count"`
}

AggregationSingleBucket is a single bucket, returned e.g. via an aggregation of type Global.

func (*AggregationSingleBucket) UnmarshalJSON Uses

func (a *AggregationSingleBucket) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes JSON data and initializes an AggregationSingleBucket structure.

type AggregationStatsMetric Uses

type AggregationStatsMetric struct {
    Aggregations

    Count int64    // `json:"count"`
    Min   *float64 //`json:"min,omitempty"`
    Max   *float64 //`json:"max,omitempty"`
    Avg   *float64 //`json:"avg,omitempty"`
    Sum   *float64 //`json:"sum,omitempty"`
}

AggregationStatsMetric is a multi-value metric, returned by a Stats aggregation.

func (*AggregationStatsMetric) UnmarshalJSON Uses

func (a *AggregationStatsMetric) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes JSON data and initializes an AggregationStatsMetric structure.

type AggregationTopHitsMetric Uses

type AggregationTopHitsMetric struct {
    Aggregations

    Hits *SearchHits //`json:"hits"`
}

AggregationTopHitsMetric is a metric returned by a TopHits aggregation.

func (*AggregationTopHitsMetric) UnmarshalJSON Uses

func (a *AggregationTopHitsMetric) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes JSON data and initializes an AggregationTopHitsMetric structure.

type AggregationValueMetric Uses

type AggregationValueMetric struct {
    Aggregations

    Value *float64 //`json:"value"`
}

AggregationValueMetric is a single-value metric, returned e.g. by a Min or Max aggregation.

func (*AggregationValueMetric) UnmarshalJSON Uses

func (a *AggregationValueMetric) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes JSON data and initializes an AggregationValueMetric structure.

type Aggregations Uses

type Aggregations map[string]*json.RawMessage

Aggregations is a list of aggregations that are part of a search result.

Code:

// Get a client to the local Elasticsearch instance.
client, err := elastic.NewClient()
if err != nil {
    // Handle error
    panic(err)
}

// Create an aggregation for users and a sub-aggregation for a date histogram of tweets (per year).
timeline := elastic.NewTermsAggregation().Field("user").Size(10).OrderByCountDesc()
histogram := elastic.NewDateHistogramAggregation().Field("created").Interval("year")
timeline = timeline.SubAggregation("history", histogram)

// Search with a term query
searchResult, err := client.Search().
    Index("twitter").                  // search in index "twitter"
    Query(elastic.NewMatchAllQuery()). // return all results, but ...
    SearchType("count").               // ... do not return hits, just the count
    Aggregation("timeline", timeline). // add our aggregation to the query
    Pretty(true).                      // pretty print request and response JSON
    Do()                               // execute
if err != nil {
    // Handle error
    panic(err)
}

// Access "timeline" aggregate in search result.
agg, found := searchResult.Aggregations.Terms("timeline")
if !found {
    log.Fatalf("we should have a terms aggregation called %q", "timeline")
}
for _, userBucket := range agg.Buckets {
    // Every bucket should have the user field as key.
    user := userBucket.Key

    // The sub-aggregation history should have the number of tweets per year.
    histogram, found := userBucket.DateHistogram("history")
    if found {
        for _, year := range histogram.Buckets {
            fmt.Printf("user %q has %d tweets in %q\n", user, year.DocCount, year.KeyAsString)
        }
    }
}

func (Aggregations) Avg Uses

func (a Aggregations) Avg(name string) (*AggregationValueMetric, bool)

Avg returns average aggregation results. See: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-metrics-avg-aggregation.html

func (Aggregations) Cardinality Uses

func (a Aggregations) Cardinality(name string) (*AggregationValueMetric, bool)

Cardinality returns cardinality aggregation results. See: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-metrics-cardinality-aggregation.html

func (Aggregations) Children Uses

func (a Aggregations) Children(name string) (*AggregationSingleBucket, bool)

Children returns children results. See: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-bucket-children-aggregation.html

func (Aggregations) DateHistogram Uses

func (a Aggregations) DateHistogram(name string) (*AggregationBucketHistogramItems, bool)

DateHistogram returns date histogram aggregation results. See: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-bucket-datehistogram-aggregation.html

func (Aggregations) DateRange Uses

func (a Aggregations) DateRange(name string) (*AggregationBucketRangeItems, bool)

DateRange returns date range aggregation results. See: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-bucket-daterange-aggregation.html

func (Aggregations) ExtendedStats Uses

func (a Aggregations) ExtendedStats(name string) (*AggregationExtendedStatsMetric, bool)

ExtendedStats returns extended stats aggregation results. See: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-metrics-extendedstats-aggregation.html

func (Aggregations) Filter Uses

func (a Aggregations) Filter(name string) (*AggregationSingleBucket, bool)

Filter returns filter results. See: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-bucket-filter-aggregation.html

func (Aggregations) Filters Uses

func (a Aggregations) Filters(name string) (*AggregationBucketFilters, bool)

Filters returns filters results. See: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-bucket-filters-aggregation.html

func (Aggregations) GeoBounds Uses

func (a Aggregations) GeoBounds(name string) (*AggregationGeoBoundsMetric, bool)

GeoBounds returns geo-bounds aggregation results. See: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-metrics-geobounds-aggregation.html

func (Aggregations) GeoDistance Uses

func (a Aggregations) GeoDistance(name string) (*AggregationBucketRangeItems, bool)

GeoDistance returns geo distance aggregation results. See: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-bucket-geodistance-aggregation.html

func (Aggregations) GeoHash Uses

func (a Aggregations) GeoHash(name string) (*AggregationBucketKeyItems, bool)

GeoHash returns geo-hash aggregation results. http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-bucket-geohashgrid-aggregation.html

func (Aggregations) Global Uses

func (a Aggregations) Global(name string) (*AggregationSingleBucket, bool)

Global returns global results. See: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-bucket-global-aggregation.html

func (Aggregations) Histogram Uses

func (a Aggregations) Histogram(name string) (*AggregationBucketHistogramItems, bool)

Histogram returns histogram aggregation results. See: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-bucket-histogram-aggregation.html

func (Aggregations) IPv4Range Uses

func (a Aggregations) IPv4Range(name string) (*AggregationBucketRangeItems, bool)

IPv4Range returns IPv4 range aggregation results. See: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-bucket-iprange-aggregation.html

func (Aggregations) KeyedRange Uses

func (a Aggregations) KeyedRange(name string) (*AggregationBucketKeyedRangeItems, bool)

KeyedRange returns keyed range aggregation results. See http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-bucket-range-aggregation.html.

func (Aggregations) Max Uses

func (a Aggregations) Max(name string) (*AggregationValueMetric, bool)

Max returns max aggregation results. See: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-metrics-max-aggregation.html

func (Aggregations) Min Uses

func (a Aggregations) Min(name string) (*AggregationValueMetric, bool)

Min returns min aggregation results. See: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-metrics-min-aggregation.html

func (Aggregations) Missing Uses

func (a Aggregations) Missing(name string) (*AggregationSingleBucket, bool)

Missing returns missing results. See: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-bucket-missing-aggregation.html

func (Aggregations) Nested Uses

func (a Aggregations) Nested(name string) (*AggregationSingleBucket, bool)

Nested returns nested results. See: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-bucket-nested-aggregation.html

func (Aggregations) PercentileRanks Uses

func (a Aggregations) PercentileRanks(name string) (*AggregationPercentilesMetric, bool)

PercentileRanks returns percentile ranks results. See: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-metrics-percentile-rank-aggregation.html

func (Aggregations) Percentiles Uses

func (a Aggregations) Percentiles(name string) (*AggregationPercentilesMetric, bool)

Percentiles returns percentiles results. See: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-metrics-percentile-aggregation.html

func (Aggregations) Range Uses

func (a Aggregations) Range(name string) (*AggregationBucketRangeItems, bool)

Range returns range aggregation results. See: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-bucket-range-aggregation.html

func (Aggregations) ReverseNested Uses

func (a Aggregations) ReverseNested(name string) (*AggregationSingleBucket, bool)

ReverseNested returns reverse-nested results. See: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-bucket-reverse-nested-aggregation.html

func (Aggregations) SignificantTerms Uses

func (a Aggregations) SignificantTerms(name string) (*AggregationBucketSignificantTerms, bool)

SignificantTerms returns significant terms aggregation results. See: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-bucket-significantterms-aggregation.html

func (Aggregations) Stats Uses

func (a Aggregations) Stats(name string) (*AggregationStatsMetric, bool)

Stats returns stats aggregation results. http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-metrics-stats-aggregation.html

func (Aggregations) Sum Uses

func (a Aggregations) Sum(name string) (*AggregationValueMetric, bool)

Sum returns sum aggregation results. See: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-metrics-sum-aggregation.html

func (Aggregations) Terms Uses

func (a Aggregations) Terms(name string) (*AggregationBucketKeyItems, bool)

Terms returns terms aggregation results. See: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html

func (Aggregations) TopHits Uses

func (a Aggregations) TopHits(name string) (*AggregationTopHitsMetric, bool)

TopHits returns top-hits aggregation results. See: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-metrics-top-hits-aggregation.html

func (Aggregations) ValueCount Uses

func (a Aggregations) ValueCount(name string) (*AggregationValueMetric, bool)

ValueCount returns value-count aggregation results. See: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-metrics-valuecount-aggregation.html

type AliasAction Uses

type AliasAction interface {
    Source() interface{}
}

AliasAction is an action to apply to an alias, e.g. "add" or "remove".

type AliasAddAction Uses

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

AliasAddAction is an action to add to an alias.

func NewAliasAddAction Uses

func NewAliasAddAction(alias string) *AliasAddAction

NewAliasAddAction returns an action to add an alias.

func (*AliasAddAction) Filter Uses

func (a *AliasAddAction) Filter(filter Filter) *AliasAddAction

Filter associates a filter to the alias.

func (*AliasAddAction) Index Uses

func (a *AliasAddAction) Index(index ...string) *AliasAddAction

Index associates one or more indices to the alias.

func (*AliasAddAction) IndexRouting Uses

func (a *AliasAddAction) IndexRouting(routing string) *AliasAddAction

IndexRouting associates an index routing value to the alias.

func (*AliasAddAction) Routing Uses

func (a *AliasAddAction) Routing(routing string) *AliasAddAction

Routing associates a routing value to the alias. This basically sets index and search routing to the same value.

func (*AliasAddAction) SearchRouting Uses

func (a *AliasAddAction) SearchRouting(routing ...string) *AliasAddAction

SearchRouting associates a search routing value to the alias.

func (*AliasAddAction) Source Uses

func (a *AliasAddAction) Source() interface{}

Source returns the JSON-serializable data.

func (*AliasAddAction) Validate Uses

func (a *AliasAddAction) Validate() error

Validate checks if the operation is valid.

type AliasRemoveAction Uses

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

AliasRemoveAction is an action to remove an alias.

func NewAliasRemoveAction Uses

func NewAliasRemoveAction(alias string) *AliasRemoveAction

NewAliasRemoveAction returns an action to remove an alias.

func (*AliasRemoveAction) Index Uses

func (a *AliasRemoveAction) Index(index ...string) *AliasRemoveAction

Index associates one or more indices to the alias.

func (*AliasRemoveAction) Source Uses

func (a *AliasRemoveAction) Source() interface{}

Source returns the JSON-serializable data.

func (*AliasRemoveAction) Validate Uses

func (a *AliasRemoveAction) Validate() error

Validate checks if the operation is valid.

type AliasResult Uses

type AliasResult struct {
    Acknowledged bool `json:"acknowledged"`
}

AliasResult is the outcome of calling Do on AliasService.

type AliasService Uses

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

AliasService enables users to add or remove an alias. See https://www.elastic.co/guide/en/elasticsearch/reference/1.7/indices-aliases.html for details.

func NewAliasService Uses

func NewAliasService(client *Client) *AliasService

NewAliasService implements a service to manage aliases.

func (*AliasService) Action Uses

func (s *AliasService) Action(action ...AliasAction) *AliasService

Action accepts one or more AliasAction instances which can be of type AliasAddAction or AliasRemoveAction.

func (*AliasService) Add Uses

func (s *AliasService) Add(indexName string, aliasName string) *AliasService

Add adds an alias to an index.

func (*AliasService) AddWithFilter Uses

func (s *AliasService) AddWithFilter(indexName string, aliasName string, filter Query) *AliasService

Add adds an alias to an index and associates a filter to the alias.

func (*AliasService) Do Uses

func (s *AliasService) Do() (*AliasResult, error)

Do executes the command.

func (*AliasService) Pretty Uses

func (s *AliasService) Pretty(pretty bool) *AliasService

Pretty asks Elasticsearch to indent the HTTP response.

func (*AliasService) Remove Uses

func (s *AliasService) Remove(indexName string, aliasName string) *AliasService

Remove removes an alias.

type AliasesResult Uses

type AliasesResult struct {
    Indices map[string]indexResult
}

func (AliasesResult) IndicesByAlias Uses

func (ar AliasesResult) IndicesByAlias(aliasName string) []string

type AliasesService Uses

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

func NewAliasesService Uses

func NewAliasesService(client *Client) *AliasesService

func (*AliasesService) Do Uses

func (s *AliasesService) Do() (*AliasesResult, error)

func (*AliasesService) Index Uses

func (s *AliasesService) Index(indexName string) *AliasesService

func (*AliasesService) Indices Uses

func (s *AliasesService) Indices(indexNames ...string) *AliasesService

func (*AliasesService) Pretty Uses

func (s *AliasesService) Pretty(pretty bool) *AliasesService

type AndFilter Uses

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

A filter that matches documents using AND boolean operator on other filters. Can be placed within queries that accept a filter. For details, see: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-and-filter.html

func NewAndFilter Uses

func NewAndFilter(filters ...Filter) AndFilter

func (AndFilter) Add Uses

func (f AndFilter) Add(filter Filter) AndFilter

func (AndFilter) Cache Uses

func (f AndFilter) Cache(cache bool) AndFilter

func (AndFilter) CacheKey Uses

func (f AndFilter) CacheKey(cacheKey string) AndFilter

func (AndFilter) FilterName Uses

func (f AndFilter) FilterName(filterName string) AndFilter

func (AndFilter) Source Uses

func (f AndFilter) Source() interface{}

type AvgAggregation Uses

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

AvgAggregation is a single-value metrics aggregation that computes the average of numeric values that are extracted from the aggregated documents. These values can be extracted either from specific numeric fields in the documents, or be generated by a provided script. See: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-metrics-avg-aggregation.html

func NewAvgAggregation Uses

func NewAvgAggregation() AvgAggregation

func (AvgAggregation) Field Uses

func (a AvgAggregation) Field(field string) AvgAggregation

func (AvgAggregation) Format Uses

func (a AvgAggregation) Format(format string) AvgAggregation

func (AvgAggregation) Lang Uses

func (a AvgAggregation) Lang(lang string) AvgAggregation

func (AvgAggregation) Param Uses

func (a AvgAggregation) Param(name string, value interface{}) AvgAggregation

func (AvgAggregation) Script Uses

func (a AvgAggregation) Script(script string) AvgAggregation

func (AvgAggregation) ScriptFile Uses

func (a AvgAggregation) ScriptFile(scriptFile string) AvgAggregation

func (AvgAggregation) Source Uses

func (a AvgAggregation) Source() interface{}

func (AvgAggregation) SubAggregation Uses

func (a AvgAggregation) SubAggregation(name string, subAggregation Aggregation) AvgAggregation

type BoolFilter Uses

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

A filter that matches documents matching boolean combinations of other queries. Similar in concept to Boolean query, except that the clauses are other filters. Can be placed within queries that accept a filter. For more details, see: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-bool-filter.html

func NewBoolFilter Uses

func NewBoolFilter() BoolFilter

NewBoolFilter creates a new bool filter.

func (BoolFilter) Cache Uses

func (f BoolFilter) Cache(cache bool) BoolFilter

func (BoolFilter) CacheKey Uses

func (f BoolFilter) CacheKey(cacheKey string) BoolFilter

func (BoolFilter) FilterName Uses

func (f BoolFilter) FilterName(filterName string) BoolFilter

func (BoolFilter) Must Uses

func (f BoolFilter) Must(filters ...Filter) BoolFilter

func (BoolFilter) MustNot Uses

func (f BoolFilter) MustNot(filters ...Filter) BoolFilter

func (BoolFilter) Should Uses

func (f BoolFilter) Should(filters ...Filter) BoolFilter

func (BoolFilter) Source Uses

func (f BoolFilter) Source() interface{}

Creates the query source for the bool query.

type BoolQuery Uses

type BoolQuery struct {
    Query
    // contains filtered or unexported fields
}

A bool query matches documents matching boolean combinations of other queries. For more details, see: http://www.elasticsearch.org/guide/reference/query-dsl/bool-query.html

func NewBoolQuery Uses

func NewBoolQuery() BoolQuery

Creates a new bool query.

func (BoolQuery) AdjustPureNegative Uses

func (q BoolQuery) AdjustPureNegative(adjustPureNegative bool) BoolQuery

func (BoolQuery) Boost Uses

func (q BoolQuery) Boost(boost float32) BoolQuery

func (BoolQuery) DisableCoord Uses

func (q BoolQuery) DisableCoord(disableCoord bool) BoolQuery

func (BoolQuery) MinimumShouldMatch Uses

func (q BoolQuery) MinimumShouldMatch(minimumShouldMatch string) BoolQuery

func (BoolQuery) Must Uses

func (q BoolQuery) Must(queries ...Query) BoolQuery

func (BoolQuery) MustNot Uses

func (q BoolQuery) MustNot(queries ...Query) BoolQuery

func (BoolQuery) QueryName Uses

func (q BoolQuery) QueryName(queryName string) BoolQuery

func (BoolQuery) Should Uses

func (q BoolQuery) Should(queries ...Query) BoolQuery

func (BoolQuery) Source Uses

func (q BoolQuery) Source() interface{}

Creates the query source for the bool query.

type BoostingQuery Uses

type BoostingQuery struct {
    Query
    // contains filtered or unexported fields
}

A boosting query can be used to effectively demote results that match a given query. For more details, see: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-boosting-query.html

func NewBoostingQuery Uses

func NewBoostingQuery() BoostingQuery

Creates a new boosting query.

func (BoostingQuery) Boost Uses

func (q BoostingQuery) Boost(boost float64) BoostingQuery

func (BoostingQuery) Negative Uses

func (q BoostingQuery) Negative(negative Query) BoostingQuery

func (BoostingQuery) NegativeBoost Uses

func (q BoostingQuery) NegativeBoost(negativeBoost float64) BoostingQuery

func (BoostingQuery) Positive Uses

func (q BoostingQuery) Positive(positive Query) BoostingQuery

func (BoostingQuery) Source Uses

func (q BoostingQuery) Source() interface{}

Creates the query source for the boosting query.

type BulkAfterFunc Uses

type BulkAfterFunc func(executionId int64, requests []BulkableRequest, response *BulkResponse, err error)

BulkAfterFunc defines the signature of callbacks that are executed after a commit to Elasticsearch. The err parameter signals an error.

type BulkBeforeFunc Uses

type BulkBeforeFunc func(executionId int64, requests []BulkableRequest)

BulkBeforeFunc defines the signature of callbacks that are executed before a commit to Elasticsearch.

type BulkDeleteRequest Uses

type BulkDeleteRequest struct {
    BulkableRequest
    // contains filtered or unexported fields
}

BulkDeleteRequest is a bulk request to remove a document from Elasticsearch.

See https://www.elastic.co/guide/en/elasticsearch/reference/1.7/docs-bulk.html for details.

func NewBulkDeleteRequest Uses

func NewBulkDeleteRequest() *BulkDeleteRequest

NewBulkDeleteRequest returns a new BulkDeleteRequest.

func (*BulkDeleteRequest) Id Uses

func (r *BulkDeleteRequest) Id(id string) *BulkDeleteRequest

Id specifies the identifier of the document to delete.

func (*BulkDeleteRequest) Index Uses

func (r *BulkDeleteRequest) Index(index string) *BulkDeleteRequest

Index specifies the Elasticsearch index to use for this delete request. If unspecified, the index set on the BulkService will be used.

func (*BulkDeleteRequest) Parent Uses

func (r *BulkDeleteRequest) Parent(parent string) *BulkDeleteRequest

Parent specifies the parent of the request, which is used in parent/child mappings.

func (*BulkDeleteRequest) Refresh Uses

func (r *BulkDeleteRequest) Refresh(refresh bool) *BulkDeleteRequest

Refresh indicates whether to update the shards immediately after the delete has been processed. Deleted documents will disappear in search immediately at the cost of slower bulk performance.

func (*BulkDeleteRequest) Routing Uses

func (r *BulkDeleteRequest) Routing(routing string) *BulkDeleteRequest

Routing specifies a routing value for the request.

func (*BulkDeleteRequest) Source Uses

func (r *BulkDeleteRequest) Source() ([]string, error)

Source returns the on-wire representation of the delete request, split into an action-and-meta-data line and an (optional) source line. See https://www.elastic.co/guide/en/elasticsearch/reference/1.7/docs-bulk.html for details.

func (*BulkDeleteRequest) String Uses

func (r *BulkDeleteRequest) String() string

String returns the on-wire representation of the delete request, concatenated as a single string.

func (*BulkDeleteRequest) Type Uses

func (r *BulkDeleteRequest) Type(typ string) *BulkDeleteRequest

Type specifies the Elasticsearch type to use for this delete request. If unspecified, the type set on the BulkService will be used.

func (*BulkDeleteRequest) Version Uses

func (r *BulkDeleteRequest) Version(version int64) *BulkDeleteRequest

Version indicates the version to be deleted as part of an optimistic concurrency model.

func (*BulkDeleteRequest) VersionType Uses

func (r *BulkDeleteRequest) VersionType(versionType string) *BulkDeleteRequest

VersionType can be "internal" (default), "external", "external_gte", "external_gt", or "force".

type BulkIndexRequest Uses

type BulkIndexRequest struct {
    BulkableRequest
    // contains filtered or unexported fields
}

BulkIndexRequest is a bulk request to add a document to Elasticsearch.

See https://www.elastic.co/guide/en/elasticsearch/reference/1.7/docs-bulk.html for details.

func NewBulkIndexRequest Uses

func NewBulkIndexRequest() *BulkIndexRequest

NewBulkIndexRequest returns a new BulkIndexRequest. The operation type is "index" by default.

func (*BulkIndexRequest) Doc Uses

func (r *BulkIndexRequest) Doc(doc interface{}) *BulkIndexRequest

Doc specifies the document to index.

func (*BulkIndexRequest) Id Uses

func (r *BulkIndexRequest) Id(id string) *BulkIndexRequest

Id specifies the identifier of the document to index.

func (*BulkIndexRequest) Index Uses

func (r *BulkIndexRequest) Index(index string) *BulkIndexRequest

Index specifies the Elasticsearch index to use for this index request. If unspecified, the index set on the BulkService will be used.

func (*BulkIndexRequest) OpType Uses

func (r *BulkIndexRequest) OpType(opType string) *BulkIndexRequest

OpType specifies if this request should follow create-only or upsert behavior. This follows the OpType of the standard document index API. See https://www.elastic.co/guide/en/elasticsearch/reference/1.7/docs-index_.html#operation-type for details.

func (*BulkIndexRequest) Parent Uses

func (r *BulkIndexRequest) Parent(parent string) *BulkIndexRequest

Parent specifies the identifier of the parent document (if available).

func (*BulkIndexRequest) Refresh Uses

func (r *BulkIndexRequest) Refresh(refresh bool) *BulkIndexRequest

Refresh indicates whether to update the shards immediately after the request has been processed. Newly added documents will appear in search immediately at the cost of slower bulk performance.

func (*BulkIndexRequest) Routing Uses

func (r *BulkIndexRequest) Routing(routing string) *BulkIndexRequest

Routing specifies a routing value for the request.

func (*BulkIndexRequest) Source Uses

func (r *BulkIndexRequest) Source() ([]string, error)

Source returns the on-wire representation of the index request, split into an action-and-meta-data line and an (optional) source line. See https://www.elastic.co/guide/en/elasticsearch/reference/1.7/docs-bulk.html for details.

func (*BulkIndexRequest) String Uses

func (r *BulkIndexRequest) String() string

String returns the on-wire representation of the index request, concatenated as a single string.

func (*BulkIndexRequest) Timestamp Uses

func (r *BulkIndexRequest) Timestamp(timestamp string) *BulkIndexRequest

Timestamp can be used to index a document with a timestamp. This is deprecated as of 2.0.0-beta2; you should use a normal date field and set its value explicitly.

func (*BulkIndexRequest) Ttl Uses

func (r *BulkIndexRequest) Ttl(ttl int64) *BulkIndexRequest

Ttl (time to live) sets an expiration date for the document. Expired documents will be expunged automatically. This is deprecated as of 2.0.0-beta2 and will be replaced by a different implementation in a future version.

func (*BulkIndexRequest) Type Uses

func (r *BulkIndexRequest) Type(typ string) *BulkIndexRequest

Type specifies the Elasticsearch type to use for this index request. If unspecified, the type set on the BulkService will be used.

func (*BulkIndexRequest) Version Uses

func (r *BulkIndexRequest) Version(version int64) *BulkIndexRequest

Version indicates the version of the document as part of an optimistic concurrency model.

func (*BulkIndexRequest) VersionType Uses

func (r *BulkIndexRequest) VersionType(versionType string) *BulkIndexRequest

VersionType specifies how versions are created. It can be e.g. internal, external, external_gte, or force.

See https://www.elastic.co/guide/en/elasticsearch/reference/1.7/docs-index_.html#index-versioning for details.

type BulkProcessor Uses

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

BulkProcessor encapsulates a task that accepts bulk requests and orchestrates committing them to Elasticsearch via one or more workers.

BulkProcessor is returned by setting up a BulkProcessorService and calling the Do method.

func (*BulkProcessor) Add Uses

func (p *BulkProcessor) Add(request BulkableRequest)

Add adds a single request to commit by the BulkProcessorService.

The caller is responsible for setting the index and type on the request.

func (*BulkProcessor) Close Uses

func (p *BulkProcessor) Close() error

Close stops the bulk processor previously started with Do. If it is already stopped, this is a no-op and nil is returned.

By implementing Close, BulkProcessor implements the io.Closer interface.

func (*BulkProcessor) Flush Uses

func (p *BulkProcessor) Flush() error

Flush manually asks all workers to commit their outstanding requests. It returns only when all workers acknowledge completion.

func (*BulkProcessor) Start Uses

func (p *BulkProcessor) Start() error

Start starts the bulk processor. If the processor is already started, nil is returned.

func (*BulkProcessor) Stats Uses

func (p *BulkProcessor) Stats() BulkProcessorStats

Stats returns the latest bulk processor statistics. Collecting stats must be enabled first by calling Stats(true) on the service that created this processor.

func (*BulkProcessor) Stop Uses

func (p *BulkProcessor) Stop() error

Stop is an alias for Close.

type BulkProcessorService Uses

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

BulkProcessorService allows to easily process bulk requests. It allows setting policies when to flush new bulk requests, e.g. based on a number of actions, on the size of the actions, and/or to flush periodically. It also allows to control the number of concurrent bulk requests allowed to be executed in parallel.

BulkProcessorService, by default, commits either every 1000 requests or when the (estimated) size of the bulk requests exceeds 5 MB. However, it does not commit periodically. BulkProcessorService also does retry by default, using an exponential backoff algorithm.

The caller is responsible for setting the index and type on every bulk request added to BulkProcessorService.

BulkProcessorService takes ideas from the BulkProcessor of the Elasticsearch Java API as documented in https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/java-docs-bulk-processor.html.

func NewBulkProcessorService Uses

func NewBulkProcessorService(client *Client) *BulkProcessorService

NewBulkProcessorService creates a new BulkProcessorService.

func (*BulkProcessorService) After Uses

func (s *BulkProcessorService) After(fn BulkAfterFunc) *BulkProcessorService

After specifies a function to be executed when bulk requests have been comitted to Elasticsearch. The After callback executes both when the commit was successful as well as on failures.

func (*BulkProcessorService) Before Uses

func (s *BulkProcessorService) Before(fn BulkBeforeFunc) *BulkProcessorService

Before specifies a function to be executed before bulk requests get comitted to Elasticsearch.

func (*BulkProcessorService) BulkActions Uses

func (s *BulkProcessorService) BulkActions(bulkActions int) *BulkProcessorService

BulkActions specifies when to flush based on the number of actions currently added. Defaults to 1000 and can be set to -1 to be disabled.

func (*BulkProcessorService) BulkSize Uses

func (s *BulkProcessorService) BulkSize(bulkSize int) *BulkProcessorService

BulkSize specifies when to flush based on the size (in bytes) of the actions currently added. Defaults to 5 MB and can be set to -1 to be disabled.

func (*BulkProcessorService) Do Uses

func (s *BulkProcessorService) Do() (*BulkProcessor, error)

Do creates a new BulkProcessor and starts it. Consider the BulkProcessor as a running instance that accepts bulk requests and commits them to Elasticsearch, spreading the work across one or more workers.

You can interoperate with the BulkProcessor returned by Do, e.g. Start and Stop (or Close) it.

Calling Do several times returns new BulkProcessors. You probably don't want to do this. BulkProcessorService implements just a builder pattern.

func (*BulkProcessorService) FlushInterval Uses

func (s *BulkProcessorService) FlushInterval(interval time.Duration) *BulkProcessorService

FlushInterval specifies when to flush at the end of the given interval. This is disabled by default. If you want the bulk processor to operate completely asynchronously, set both BulkActions and BulkSize to -1 and set the FlushInterval to a meaningful interval.

func (*BulkProcessorService) Name Uses

func (s *BulkProcessorService) Name(name string) *BulkProcessorService

Name is an optional name to identify this bulk processor.

func (*BulkProcessorService) Stats Uses

func (s *BulkProcessorService) Stats(wantStats bool) *BulkProcessorService

Stats tells bulk processor to gather stats while running. Use Stats to return the stats. This is disabled by default.

func (*BulkProcessorService) Workers Uses

func (s *BulkProcessorService) Workers(num int) *BulkProcessorService

Workers is the number of concurrent workers allowed to be executed. Defaults to 1 and must be greater or equal to 1.

type BulkProcessorStats Uses

type BulkProcessorStats struct {
    Flushed   int64 // number of times the flush interval has been invoked
    Committed int64 // # of times workers committed bulk requests
    Indexed   int64 // # of requests indexed
    Created   int64 // # of requests that ES reported as creates (201)
    Updated   int64 // # of requests that ES reported as updates
    Deleted   int64 // # of requests that ES reported as deletes
    Succeeded int64 // # of requests that ES reported as successful
    Failed    int64 // # of requests that ES reported as failed

    Workers []*BulkProcessorWorkerStats // stats for each worker
}

BulkProcessorStats contains various statistics of a bulk processor while it is running. Use the Stats func to return it while running.

type BulkProcessorWorkerStats Uses

type BulkProcessorWorkerStats struct {
    Queued       int64         // # of requests queued in this worker
    LastDuration time.Duration // duration of last commit
}

BulkProcessorWorkerStats represents per-worker statistics.

type BulkResponse Uses

type BulkResponse struct {
    Took   int                            `json:"took,omitempty"`
    Errors bool                           `json:"errors,omitempty"`
    Items  []map[string]*BulkResponseItem `json:"items,omitempty"`
}

BulkResponse is a response to a bulk execution.

Example: {

"took":3,
"errors":false,
"items":[{
  "index":{
    "_index":"index1",
    "_type":"tweet",
    "_id":"1",
    "_version":3,
    "status":201
  }
},{
  "index":{
    "_index":"index2",
    "_type":"tweet",
    "_id":"2",
    "_version":3,
    "status":200
  }
},{
  "delete":{
    "_index":"index1",
    "_type":"tweet",
    "_id":"1",
    "_version":4,
    "status":200,
    "found":true
  }
},{
  "update":{
    "_index":"index2",
    "_type":"tweet",
    "_id":"2",
    "_version":4,
    "status":200
  }
}]

}

func (*BulkResponse) ByAction Uses

func (r *BulkResponse) ByAction(action string) []*BulkResponseItem

ByAction returns all bulk request results of a certain action, e.g. "index" or "delete".

func (*BulkResponse) ById Uses

func (r *BulkResponse) ById(id string) []*BulkResponseItem

ById returns all bulk request results of a given document id, regardless of the action ("index", "delete" etc.).

func (*BulkResponse) Created Uses

func (r *BulkResponse) Created() []*BulkResponseItem

Created returns all bulk request results of "create" actions.

func (*BulkResponse) Deleted Uses

func (r *BulkResponse) Deleted() []*BulkResponseItem

Deleted returns all bulk request results of "delete" actions.

func (*BulkResponse) Failed Uses

func (r *BulkResponse) Failed() []*BulkResponseItem

Failed returns those items of a bulk response that have errors, i.e. those that don't have a status code between 200 and 299.

func (*BulkResponse) Indexed Uses

func (r *BulkResponse) Indexed() []*BulkResponseItem

Indexed returns all bulk request results of "index" actions.

func (*BulkResponse) Succeeded Uses

func (r *BulkResponse) Succeeded() []*BulkResponseItem

Succeeded returns those items of a bulk response that have no errors, i.e. those have a status code between 200 and 299.

func (*BulkResponse) Updated Uses

func (r *BulkResponse) Updated() []*BulkResponseItem

Updated returns all bulk request results of "update" actions.

type BulkResponseItem Uses

type BulkResponseItem struct {
    Index   string `json:"_index,omitempty"`
    Type    string `json:"_type,omitempty"`
    Id      string `json:"_id,omitempty"`
    Version int    `json:"_version,omitempty"`
    Status  int    `json:"status,omitempty"`
    Found   bool   `json:"found,omitempty"`
    Error   string `json:"error,omitempty"`
}

BulkResponseItem is the result of a single bulk request.

type BulkService Uses

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

BulkService allows for batching bulk requests and sending them to Elasticsearch in one roundtrip. Use the Add method with BulkIndexRequest, BulkUpdateRequest, and BulkDeleteRequest to add bulk requests to a batch, then use Do to send them to Elasticsearch.

BulkService will be reset after each Do call. In other words, you can reuse BulkService to send many batches. You do not have to create a new BulkService for each batch.

See https://www.elastic.co/guide/en/elasticsearch/reference/1.7/docs-bulk.html for more details.

func NewBulkService Uses

func NewBulkService(client *Client) *BulkService

NewBulkService initializes a new BulkService.

func (*BulkService) Add Uses

func (s *BulkService) Add(requests ...BulkableRequest) *BulkService

Add adds bulkable requests, i.e. BulkIndexRequest, BulkUpdateRequest, and/or BulkDeleteRequest.

func (*BulkService) Do Uses

func (s *BulkService) Do() (*BulkResponse, error)

Do sends the batched requests to Elasticsearch. Note that, when successful, you can reuse the BulkService for the next batch as the list of bulk requests is cleared on success.

func (*BulkService) EstimatedSizeInBytes Uses

func (s *BulkService) EstimatedSizeInBytes() int64

EstimatedSizeInBytes returns the estimated size of all bulkable requests added via Add.

func (*BulkService) Index Uses

func (s *BulkService) Index(index string) *BulkService

Index specifies the index to use for all batches. You may also leave this blank and specify the index in the individual bulk requests.

func (*BulkService) NumberOfActions Uses

func (s *BulkService) NumberOfActions() int

NumberOfActions returns the number of bulkable requests that need to be sent to Elasticsearch on the next batch.

func (*BulkService) Pretty Uses

func (s *BulkService) Pretty(pretty bool) *BulkService

Pretty tells Elasticsearch whether to return a formatted JSON response.

func (*BulkService) Refresh Uses

func (s *BulkService) Refresh(refresh bool) *BulkService

Refresh indicates whether Elasticsearch to make the bulk requests available to search immediately after being processed. Normally, this only happens after a specified refresh interval.

func (*BulkService) Timeout Uses

func (s *BulkService) Timeout(timeout string) *BulkService

Timeout is a global timeout for processing bulk requests. This is a server-side timeout, i.e. it tells Elasticsearch the time after which it should stop processing.

func (*BulkService) Type Uses

func (s *BulkService) Type(typ string) *BulkService

Type specifies the type to use for all batches. You may also leave this blank and specify the type in the individual bulk requests.

type BulkUpdateRequest Uses

type BulkUpdateRequest struct {
    BulkableRequest
    // contains filtered or unexported fields
}

Bulk request to update a document in Elasticsearch.

See https://www.elastic.co/guide/en/elasticsearch/reference/1.7/docs-bulk.html for details.

func NewBulkUpdateRequest Uses

func NewBulkUpdateRequest() *BulkUpdateRequest

NewBulkUpdateRequest returns a new BulkUpdateRequest.

func (*BulkUpdateRequest) Doc Uses

func (r *BulkUpdateRequest) Doc(doc interface{}) *BulkUpdateRequest

Doc specifies the updated document.

func (*BulkUpdateRequest) DocAsUpsert Uses

func (r *BulkUpdateRequest) DocAsUpsert(docAsUpsert bool) *BulkUpdateRequest

DocAsUpsert indicates whether the contents of Doc should be used as the Upsert value.

See https://www.elastic.co/guide/en/elasticsearch/reference/1.7/docs-update.html#_literal_doc_as_upsert_literal for details.

func (*BulkUpdateRequest) Id Uses

func (r *BulkUpdateRequest) Id(id string) *BulkUpdateRequest

Id specifies the identifier of the document to update.

func (*BulkUpdateRequest) Index Uses

func (r *BulkUpdateRequest) Index(index string) *BulkUpdateRequest

Index specifies the Elasticsearch index to use for this update request. If unspecified, the index set on the BulkService will be used.

func (*BulkUpdateRequest) Parent Uses

func (r *BulkUpdateRequest) Parent(parent string) *BulkUpdateRequest

Parent specifies the identifier of the parent document (if available).

func (*BulkUpdateRequest) Refresh Uses

func (r *BulkUpdateRequest) Refresh(refresh bool) *BulkUpdateRequest

Refresh indicates whether to update the shards immediately after the request has been processed. Updated documents will appear in search immediately at the cost of slower bulk performance.

func (*BulkUpdateRequest) RetryOnConflict Uses

func (r *BulkUpdateRequest) RetryOnConflict(retryOnConflict int) *BulkUpdateRequest

RetryOnConflict specifies how often to retry in case of a version conflict.

func (*BulkUpdateRequest) Routing Uses

func (r *BulkUpdateRequest) Routing(routing string) *BulkUpdateRequest

Routing specifies a routing value for the request.

func (*BulkUpdateRequest) Script Uses

func (r *BulkUpdateRequest) Script(script string) *BulkUpdateRequest

Script specifies the update script.

func (*BulkUpdateRequest) ScriptLang Uses

func (r *BulkUpdateRequest) ScriptLang(scriptLang string) *BulkUpdateRequest

ScriptLang specifies the language of the update script.

func (*BulkUpdateRequest) ScriptParams Uses

func (r *BulkUpdateRequest) ScriptParams(params map[string]interface{}) *BulkUpdateRequest

ScriptParams specifies parameters to pass to the update script.

func (*BulkUpdateRequest) ScriptType Uses

func (r *BulkUpdateRequest) ScriptType(scriptType string) *BulkUpdateRequest

ScriptType specifies the type of the update script.

func (BulkUpdateRequest) Source Uses

func (r BulkUpdateRequest) Source() ([]string, error)

Source returns the on-wire representation of the update request, split into an action-and-meta-data line and an (optional) source line. See https://www.elastic.co/guide/en/elasticsearch/reference/1.7/docs-bulk.html for details.

func (*BulkUpdateRequest) String Uses

func (r *BulkUpdateRequest) String() string

String returns the on-wire representation of the update request, concatenated as a single string.

func (*BulkUpdateRequest) Timestamp Uses

func (r *BulkUpdateRequest) Timestamp(timestamp string) *BulkUpdateRequest

Timestamp specifies a timestamp for the document. This is deprecated as of 2.0.0-beta2.

func (*BulkUpdateRequest) Ttl Uses

func (r *BulkUpdateRequest) Ttl(ttl int64) *BulkUpdateRequest

Ttl specifies the time to live, and optional expiry time. This is deprecated as of 2.0.0-beta2.

func (*BulkUpdateRequest) Type Uses

func (r *BulkUpdateRequest) Type(typ string) *BulkUpdateRequest

Type specifies the Elasticsearch type to use for this update request. If unspecified, the type set on the BulkService will be used.

func (*BulkUpdateRequest) Upsert Uses

func (r *BulkUpdateRequest) Upsert(doc interface{}) *BulkUpdateRequest

Upsert specifies the document to use for upserts. It will be used for create if the original document does not exist.

func (*BulkUpdateRequest) Version Uses

func (r *BulkUpdateRequest) Version(version int64) *BulkUpdateRequest

Version indicates the version of the document as part of an optimistic concurrency model.

func (*BulkUpdateRequest) VersionType Uses

func (r *BulkUpdateRequest) VersionType(versionType string) *BulkUpdateRequest

VersionType can be "internal" (default), "external", "external_gte", "external_gt", or "force".

type BulkableRequest Uses

type BulkableRequest interface {
    fmt.Stringer
    Source() ([]string, error)
}

Generic interface to bulkable requests.

type CandidateGenerator Uses

type CandidateGenerator interface {
    Type() string
    Source() interface{}
}

type CardinalityAggregation Uses

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

CardinalityAggregation is a single-value metrics aggregation that calculates an approximate count of distinct values. Values can be extracted either from specific fields in the document or generated by a script. See: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-metrics-cardinality-aggregation.html

func NewCardinalityAggregation Uses

func NewCardinalityAggregation() CardinalityAggregation

func (CardinalityAggregation) Field Uses

func (a CardinalityAggregation) Field(field string) CardinalityAggregation

func (CardinalityAggregation) Format Uses

func (a CardinalityAggregation) Format(format string) CardinalityAggregation

func (CardinalityAggregation) Lang Uses

func (a CardinalityAggregation) Lang(lang string) CardinalityAggregation

func (CardinalityAggregation) Param Uses

func (a CardinalityAggregation) Param(name string, value interface{}) CardinalityAggregation

func (CardinalityAggregation) PrecisionThreshold Uses

func (a CardinalityAggregation) PrecisionThreshold(threshold int64) CardinalityAggregation

func (CardinalityAggregation) Rehash Uses

func (a CardinalityAggregation) Rehash(rehash bool) CardinalityAggregation

func (CardinalityAggregation) Script Uses

func (a CardinalityAggregation) Script(script string) CardinalityAggregation

func (CardinalityAggregation) ScriptFile Uses

func (a CardinalityAggregation) ScriptFile(scriptFile string) CardinalityAggregation

func (CardinalityAggregation) Source Uses

func (a CardinalityAggregation) Source() interface{}

func (CardinalityAggregation) SubAggregation Uses

func (a CardinalityAggregation) SubAggregation(name string, subAggregation Aggregation) CardinalityAggregation

type ChildrenAggregation Uses

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

ChildrenAggregation is a special single bucket aggregation that enables aggregating from buckets on parent document types to buckets on child documents. It is available from 1.4.0.Beta1 upwards. See: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-bucket-children-aggregation.html

func NewChildrenAggregation Uses

func NewChildrenAggregation() ChildrenAggregation

func (ChildrenAggregation) Source Uses

func (a ChildrenAggregation) Source() interface{}

func (ChildrenAggregation) SubAggregation Uses

func (a ChildrenAggregation) SubAggregation(name string, subAggregation Aggregation) ChildrenAggregation

func (ChildrenAggregation) Type Uses

func (a ChildrenAggregation) Type(typ string) ChildrenAggregation

type ClearScrollResponse Uses

type ClearScrollResponse struct {
}

ClearScrollResponse is the response of ClearScrollService.Do.

type ClearScrollService Uses

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

ClearScrollService is documented at http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.4/search-request-scroll.html.

func NewClearScrollService Uses

func NewClearScrollService(client *Client) *ClearScrollService

NewClearScrollService creates a new ClearScrollService.

func (*ClearScrollService) Do Uses

func (s *ClearScrollService) Do() (*ClearScrollResponse, error)

Do executes the operation.

func (*ClearScrollService) ScrollId Uses

func (s *ClearScrollService) ScrollId(scrollId ...string) *ClearScrollService

ScrollId is a list of scroll IDs to clear. Use _all to clear all search contexts.

func (*ClearScrollService) Validate Uses

func (s *ClearScrollService) Validate() error

Validate checks if the operation is valid.

type Client Uses

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

Client is an Elasticsearch client. Create one by calling NewClient.

func NewClient Uses

func NewClient(options ...ClientOptionFunc) (*Client, error)

NewClient creates a new client to work with Elasticsearch.

NewClient, by default, is meant to be long-lived and shared across your application. If you need a short-lived client, e.g. for request-scope, consider using NewSimpleClient instead.

The caller can configure the new client by passing configuration options to the func.

Example:

client, err := elastic.NewClient(
  elastic.SetURL("http://127.0.0.1:9200", "http://127.0.0.1:9201"),
  elastic.SetMaxRetries(10),
  elastic.SetBasicAuth("user", "secret"))

If no URL is configured, Elastic uses DefaultURL by default.

If the sniffer is enabled (the default), the new client then sniffes the cluster via the Nodes Info API (see http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/cluster-nodes-info.html#cluster-nodes-info). It uses the URLs specified by the caller. The caller is responsible to only pass a list of URLs of nodes that belong to the same cluster. This sniffing process is run on startup and periodically. Use SnifferInterval to set the interval between two sniffs (default is 15 minutes). In other words: By default, the client will find new nodes in the cluster and remove those that are no longer available every 15 minutes. Disable the sniffer by passing SetSniff(false) to NewClient.

The list of nodes found in the sniffing process will be used to make connections to the REST API of Elasticsearch. These nodes are also periodically checked in a shorter time frame. This process is called a health check. By default, a health check is done every 60 seconds. You can set a shorter or longer interval by SetHealthcheckInterval. Disabling health checks is not recommended, but can be done by SetHealthcheck(false).

Connections are automatically marked as dead or healthy while making requests to Elasticsearch. When a request fails, Elastic will retry up to a maximum number of retries configured with SetMaxRetries. Retries are disabled by default.

If no HttpClient is configured, then http.DefaultClient is used. You can use your own http.Client with some http.Transport for advanced scenarios.

An error is also returned when some configuration option is invalid or the new client cannot sniff the cluster (if enabled).

func NewSimpleClient Uses

func NewSimpleClient(options ...ClientOptionFunc) (*Client, error)

NewSimpleClient creates a new short-lived Client that can be used in use cases where you need e.g. one client per request.

While NewClient by default sets up e.g. periodic health checks and sniffing for new nodes in separate goroutines, NewSimpleClient does not and is meant as a simple replacement where you don't need all the heavy lifting of NewClient.

NewSimpleClient does the following by default: First, all health checks are disabled, including timeouts and periodic checks. Second, sniffing is disabled, including timeouts and periodic checks. The number of retries is set to 1. NewSimpleClient also does not start any goroutines.

Notice that you can still override settings by passing additional options, just like with NewClient.

func (*Client) Alias Uses

func (c *Client) Alias() *AliasService

Alias enables the caller to add and/or remove aliases.

func (*Client) Aliases Uses

func (c *Client) Aliases() *AliasesService

Aliases returns aliases by index name(s).

func (*Client) Bulk Uses

func (c *Client) Bulk() *BulkService

Bulk is the entry point to mass insert/update/delete documents.

func (*Client) BulkProcessor Uses

func (c *Client) BulkProcessor() *BulkProcessorService

BulkProcessor allows setting up a concurrent processor of bulk requests.

func (*Client) ClearScroll Uses

func (c *Client) ClearScroll() *ClearScrollService

ClearScroll can be used to clear search contexts manually.

func (*Client) CloseIndex Uses

func (c *Client) CloseIndex(name string) *CloseIndexService

CloseIndex closes an index.

func (*Client) ClusterHealth Uses

func (c *Client) ClusterHealth() *ClusterHealthService

ClusterHealth retrieves the health of the cluster.

func (*Client) ClusterState Uses

func (c *Client) ClusterState() *ClusterStateService

ClusterState retrieves the state of the cluster.

func (*Client) ClusterStats Uses

func (c *Client) ClusterStats() *ClusterStatsService

ClusterStats retrieves cluster statistics.

func (*Client) Count Uses

func (c *Client) Count(indices ...string) *CountService

Count documents.

func (*Client) CreateIndex Uses

func (c *Client) CreateIndex(name string) *CreateIndexService

CreateIndex returns a service to create a new index.

func (*Client) Delete Uses

func (c *Client) Delete() *DeleteService

Delete a document.

func (*Client) DeleteByQuery Uses

func (c *Client) DeleteByQuery() *DeleteByQueryService

DeleteByQuery deletes documents as found by a query.

func (*Client) DeleteIndex Uses

func (c *Client) DeleteIndex(name string) *DeleteIndexService

DeleteIndex returns a service to delete an index.

func (*Client) DeleteMapping Uses

func (c *Client) DeleteMapping() *DeleteMappingService

DeleteMapping deletes a mapping.

func (*Client) DeleteTemplate Uses

func (c *Client) DeleteTemplate() *DeleteTemplateService

DeleteTemplate deletes a search template. Use IndexXXXTemplate funcs to manage index templates.

func (*Client) DeleteWarmer Uses

func (c *Client) DeleteWarmer() *IndicesDeleteWarmerService

DeleteWarmer deletes one or more warmers.

func (*Client) ElasticsearchVersion Uses

func (c *Client) ElasticsearchVersion(url string) (string, error)

ElasticsearchVersion returns the version number of Elasticsearch running on the given URL.

func (*Client) Exists Uses

func (c *Client) Exists() *ExistsService

Exists checks if a document exists.

func (*Client) Explain Uses

func (c *Client) Explain(index, typ, id string) *ExplainService

Explain computes a score explanation for a query and a specific document.

func (*Client) FieldStats Uses

func (c *Client) FieldStats(indices ...string) *FieldStatsService

FieldStats returns statistical information about fields in indices

func (*Client) Flush Uses

func (c *Client) Flush(indices ...string) *FlushService

Flush asks Elasticsearch to free memory from the index and flush data to disk.

func (*Client) Get Uses

func (c *Client) Get() *GetService

Get a document.

func (*Client) GetMapping Uses

func (c *Client) GetMapping() *GetMappingService

GetMapping gets a mapping.

func (*Client) GetTemplate Uses

func (c *Client) GetTemplate() *GetTemplateService

GetTemplate gets a search template. Use IndexXXXTemplate funcs to manage index templates.

func (*Client) GetWarmer Uses

func (c *Client) GetWarmer() *IndicesGetWarmerService

GetWarmer gets one or more warmers by name.

func (*Client) Index Uses

func (c *Client) Index() *IndexService

Index a document.

func (*Client) IndexDeleteTemplate Uses

func (c *Client) IndexDeleteTemplate(name string) *IndicesDeleteTemplateService

IndexDeleteTemplate deletes an index template. Use XXXTemplate funcs to manage search templates.

func (*Client) IndexExists Uses

func (c *Client) IndexExists(name string) *IndexExistsService

IndexExists allows to check if an index exists.

func (*Client) IndexGet Uses

func (c *Client) IndexGet() *IndicesGetService

IndexGet retrieves information about one or more indices. IndexGet is only available for Elasticsearch 1.4 or later.

func (*Client) IndexGetSettings Uses

func (c *Client) IndexGetSettings(indices ...string) *IndicesGetSettingsService

IndexGetSettings retrieves settings of all, one or more indices.

func (*Client) IndexGetTemplate Uses

func (c *Client) IndexGetTemplate(names ...string) *IndicesGetTemplateService

IndexGetTemplate gets an index template. Use XXXTemplate funcs to manage search templates.

func (*Client) IndexNames Uses

func (c *Client) IndexNames() ([]string, error)

IndexNames returns the names of all indices in the cluster.

func (*Client) IndexPutSettings Uses

func (c *Client) IndexPutSettings(indices ...string) *IndicesPutSettingsService

IndexPutSettings sets settings for all, one or more indices.

func (*Client) IndexPutTemplate Uses

func (c *Client) IndexPutTemplate(name string) *IndicesPutTemplateService

IndexPutTemplate creates or updates an index template. Use XXXTemplate funcs to manage search templates.

func (*Client) IndexStats Uses

func (c *Client) IndexStats(indices ...string) *IndicesStatsService

IndexStats provides statistics on different operations happining in one or more indices.

func (*Client) IndexTemplateExists Uses

func (c *Client) IndexTemplateExists(name string) *IndicesExistsTemplateService

IndexTemplateExists gets check if an index template exists. Use XXXTemplate funcs to manage search templates.

func (*Client) IsRunning Uses

func (c *Client) IsRunning() bool

IsRunning returns true if the background processes of the client are running, false otherwise.

func (*Client) MultiGet Uses

func (c *Client) MultiGet() *MultiGetService

MultiGet retrieves multiple documents in one roundtrip.

func (*Client) MultiSearch Uses

func (c *Client) MultiSearch() *MultiSearchService

MultiSearch is the entry point for multi searches.

func (*Client) MultiTermVectors Uses

func (c *Client) MultiTermVectors() *MultiTermvectorService

MultiTermVectors returns information and statistics on terms in the fields of multiple documents.

func (*Client) NodesInfo Uses

func (c *Client) NodesInfo() *NodesInfoService

NodesInfo retrieves one or more or all of the cluster nodes information.

func (*Client) NodesStats Uses

func (c *Client) NodesStats() *NodesStatsService

NodesStats retrieves one or more or all of the cluster nodes statistics.

func (*Client) OpenIndex Uses

func (c *Client) OpenIndex(name string) *OpenIndexService

OpenIndex opens an index.

func (*Client) Optimize Uses

func (c *Client) Optimize(indices ...string) *OptimizeService

Optimize asks Elasticsearch to optimize one or more indices.

func (*Client) Percolate Uses

func (c *Client) Percolate() *PercolateService

Percolate allows to send a document and return matching queries. See http://www.elastic.co/guide/en/elasticsearch/reference/current/search-percolate.html.

func (*Client) PerformRequest Uses

func (c *Client) PerformRequest(method, path string, params url.Values, body interface{}, ignoreErrors ...int) (*Response, error)

PerformRequest does a HTTP request to Elasticsearch. It returns a response (which might be nil) and an error on failure.

Optionally, a list of HTTP error codes to ignore can be passed. This is necessary for services that expect e.g. HTTP status 404 as a valid outcome (Exists, IndicesExists, IndicesTypeExists).

func (*Client) Ping Uses

func (c *Client) Ping() *PingService

Ping checks if a given node in a cluster exists and (optionally) returns some basic information about the Elasticsearch server, e.g. the Elasticsearch version number.

func (*Client) PutMapping Uses

func (c *Client) PutMapping() *PutMappingService

PutMapping registers a mapping.

func (*Client) PutTemplate Uses

func (c *Client) PutTemplate() *PutTemplateService

PutTemplate creates or updates a search template. Use IndexXXXTemplate funcs to manage index templates.

func (*Client) PutWarmer Uses

func (c *Client) PutWarmer() *IndicesPutWarmerService

PutWarmer registers a warmer.

func (*Client) Refresh Uses

func (c *Client) Refresh(indices ...string) *RefreshService

Refresh asks Elasticsearch to refresh one or more indices.

func (*Client) Reindex Uses

func (c *Client) Reindex(sourceIndex, targetIndex string) *Reindexer

Reindex returns a service that will reindex documents from a source index into a target index. See http://www.elastic.co/guide/en/elasticsearch/guide/current/reindex.html for more information about reindexing.

func (*Client) Scan Uses

func (c *Client) Scan(indices ...string) *ScanService

Scan through documents. Use this to iterate inside a server process where the results will be processed without returning them to a client.

func (*Client) Scroll Uses

func (c *Client) Scroll(indices ...string) *ScrollService

Scroll through documents. Use this to efficiently scroll through results while returning the results to a client. Use Scan when you don't need to return requests to a client (i.e. not paginating via request/response).

func (*Client) Search Uses

func (c *Client) Search(indices ...string) *SearchService

Search is the entry point for searches.

func (*Client) Start Uses

func (c *Client) Start()

Start starts the background processes like sniffing the cluster and periodic health checks. You don't need to run Start when creating a client with NewClient; the background processes are run by default.

If the background processes are already running, this is a no-op.

func (*Client) Stop Uses

func (c *Client) Stop()

Stop stops the background processes that the client is running, i.e. sniffing the cluster periodically and running health checks on the nodes.

If the background processes are not running, this is a no-op.

func (*Client) String Uses

func (c *Client) String() string

String returns a string representation of the client status.

func (*Client) Suggest Uses

func (c *Client) Suggest(indices ...string) *SuggestService

Suggest returns a service to return suggestions.

func (*Client) TermVector Uses

func (c *Client) TermVector(index, typ string) *TermvectorService

TermVector returns information and statistics on terms in the fields of a particular document.

func (*Client) TypeExists Uses

func (c *Client) TypeExists() *IndicesExistsTypeService

TypeExists allows to check if one or more types exist in one or more indices.

func (*Client) Update Uses

func (c *Client) Update() *UpdateService

Update a document.

func (*Client) WaitForGreenStatus Uses

func (c *Client) WaitForGreenStatus(timeout string) error

WaitForGreenStatus waits for the cluster to have the "green" status. See WaitForStatus for more details.

func (*Client) WaitForStatus Uses

func (c *Client) WaitForStatus(status string, timeout string) error

WaitForStatus waits for the cluster to have the given status. This is a shortcut method for the ClusterHealth service.

WaitForStatus waits for the specified timeout, e.g. "10s". If the cluster will have the given state within the timeout, nil is returned. If the request timed out, ErrTimeout is returned.

func (*Client) WaitForYellowStatus Uses

func (c *Client) WaitForYellowStatus(timeout string) error

WaitForYellowStatus waits for the cluster to have the "yellow" status. See WaitForStatus for more details.

type ClientOptionFunc Uses

type ClientOptionFunc func(*Client) error

ClientOptionFunc is a function that configures a Client. It is used in NewClient.

func SetBasicAuth Uses

func SetBasicAuth(username, password string) ClientOptionFunc

SetBasicAuth can be used to specify the HTTP Basic Auth credentials to use when making HTTP requests to Elasticsearch.

func SetDecoder Uses

func SetDecoder(decoder Decoder) ClientOptionFunc

SetDecoder sets the Decoder to use when decoding data from Elasticsearch. DefaultDecoder is used by default.

func SetErrorLog Uses

func SetErrorLog(logger Logger) ClientOptionFunc

SetErrorLog sets the logger for critical messages like nodes joining or leaving the cluster or failing requests. It is nil by default.

func SetGzip Uses

func SetGzip(enabled bool) ClientOptionFunc

SetGzip enables or disables gzip compression (disabled by default).

func SetHealthcheck Uses

func SetHealthcheck(enabled bool) ClientOptionFunc

SetHealthcheck enables or disables healthchecks (enabled by default).

func SetHealthcheckInterval Uses

func SetHealthcheckInterval(interval time.Duration) ClientOptionFunc

SetHealthcheckInterval sets the interval between two health checks. The default interval is 60 seconds.

func SetHealthcheckTimeout Uses

func SetHealthcheckTimeout(timeout time.Duration) ClientOptionFunc

SetHealthcheckTimeout sets the timeout for periodic health checks. The default timeout is 1 second (see DefaultHealthcheckTimeout). Notice that a different (usually larger) timeout is used for the initial healthcheck, which is initiated while creating a new client. The startup timeout can be modified with SetHealthcheckTimeoutStartup.

func SetHealthcheckTimeoutStartup Uses

func SetHealthcheckTimeoutStartup(timeout time.Duration) ClientOptionFunc

SetHealthcheckTimeoutStartup sets the timeout for the initial health check. The default timeout is 5 seconds (see DefaultHealthcheckTimeoutStartup). Notice that timeouts for subsequent health checks can be modified with SetHealthcheckTimeout.

func SetHttpClient Uses

func SetHttpClient(httpClient *http.Client) ClientOptionFunc

SetHttpClient can be used to specify the http.Client to use when making HTTP requests to Elasticsearch.

func SetInfoLog Uses

func SetInfoLog(logger Logger) ClientOptionFunc

SetInfoLog sets the logger for informational messages, e.g. requests and their response times. It is nil by default.

func SetMaxRetries Uses

func SetMaxRetries(maxRetries int) ClientOptionFunc

SetMaxRetries sets the maximum number of retries before giving up when performing a HTTP request to Elasticsearch.

func SetScheme Uses

func SetScheme(scheme string) ClientOptionFunc

SetScheme sets the HTTP scheme to look for when sniffing (http or https). This is http by default.

func SetSendGetBodyAs Uses

func SetSendGetBodyAs(httpMethod string) ClientOptionFunc

SendGetBodyAs specifies the HTTP method to use when sending a GET request with a body. It is GET by default.

func SetSniff Uses

func SetSniff(enabled bool) ClientOptionFunc

SetSniff enables or disables the sniffer (enabled by default).

func SetSnifferInterval Uses

func SetSnifferInterval(interval time.Duration) ClientOptionFunc

SetSnifferInterval sets the interval between two sniffing processes. The default interval is 15 minutes.

func SetSnifferTimeout Uses

func SetSnifferTimeout(timeout time.Duration) ClientOptionFunc

SetSnifferTimeout sets the timeout for the sniffer that finds the nodes in a cluster. The default is 2 seconds. Notice that the timeout used when creating a new client on startup is usually greater and can be set with SetSnifferTimeoutStartup.

func SetSnifferTimeoutStartup Uses

func SetSnifferTimeoutStartup(timeout time.Duration) ClientOptionFunc

SetSnifferTimeoutStartup sets the timeout for the sniffer that is used when creating a new client. The default is 5 seconds. Notice that the timeout being used for subsequent sniffing processes is set with SetSnifferTimeout.

func SetTraceLog Uses

func SetTraceLog(logger Logger) ClientOptionFunc

SetTraceLog specifies the log.Logger to use for output of HTTP requests and responses which is helpful during debugging. It is nil by default.

func SetURL Uses

func SetURL(urls ...string) ClientOptionFunc

SetURL defines the URL endpoints of the Elasticsearch nodes. Notice that when sniffing is enabled, these URLs are used to initially sniff the cluster on startup.

type CloseIndexResponse Uses

type CloseIndexResponse struct {
    Acknowledged bool `json:"acknowledged"`
}

CloseIndexResponse is the response of CloseIndexService.Do.

type CloseIndexService Uses

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

CloseIndexService closes an index. See documentation at http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.4/indices-open-close.html.

func NewCloseIndexService Uses

func NewCloseIndexService(client *Client) *CloseIndexService

NewCloseIndexService creates a new CloseIndexService.

func (*CloseIndexService) AllowNoIndices Uses

func (s *CloseIndexService) AllowNoIndices(allowNoIndices bool) *CloseIndexService

AllowNoIndices indicates whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified).

func (*CloseIndexService) Do Uses

func (s *CloseIndexService) Do() (*CloseIndexResponse, error)

Do executes the operation.

func (*CloseIndexService) ExpandWildcards Uses

func (s *CloseIndexService) ExpandWildcards(expandWildcards string) *CloseIndexService

ExpandWildcards indicates whether to expand wildcard expression to concrete indices that are open, closed or both.

func (*CloseIndexService) IgnoreUnavailable Uses

func (s *CloseIndexService) IgnoreUnavailable(ignoreUnavailable bool) *CloseIndexService

IgnoreUnavailable indicates whether specified concrete indices should be ignored when unavailable (missing or closed).

func (*CloseIndexService) Index Uses

func (s *CloseIndexService) Index(index string) *CloseIndexService

Index is the name of the index.

func (*CloseIndexService) MasterTimeout Uses

func (s *CloseIndexService) MasterTimeout(masterTimeout string) *CloseIndexService

MasterTimeout specifies the timeout for connection to master.

func (*CloseIndexService) Timeout Uses

func (s *CloseIndexService) Timeout(timeout string) *CloseIndexService

Timeout is an explicit operation timeout.

func (*CloseIndexService) Validate Uses

func (s *CloseIndexService) Validate() error

Validate checks if the operation is valid.

type ClusterHealthResponse Uses

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"`
    NumberOfPendingTasks int    `json:"number_of_pending_tasks"`
}

ClusterHealthResponse is the response of ClusterHealthService.Do.

type ClusterHealthService Uses

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

ClusterHealthService allows to get the status of the cluster. It is documented at http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.4/cluster-health.html.

Code:

client, err := elastic.NewClient()
if err != nil {
    panic(err)
}

// Get cluster health
res, err := client.ClusterHealth().Index("twitter").Do()
if err != nil {
    panic(err)
}
if res == nil {
    panic(err)
}
fmt.Printf("Cluster status is %q\n", res.Status)

func NewClusterHealthService Uses

func NewClusterHealthService(client *Client) *ClusterHealthService

NewClusterHealthService creates a new ClusterHealthService.

func (*ClusterHealthService) Do Uses

func (s *ClusterHealthService) Do() (*ClusterHealthResponse, error)

Do executes the operation.

func (*ClusterHealthService) Index Uses

func (s *ClusterHealthService) Index(index string) *ClusterHealthService

Index limits the information returned to a specific index.

func (*ClusterHealthService) Indices Uses

func (s *ClusterHealthService) Indices(indices ...string) *ClusterHealthService

Indices limits the information returned to specific indices.

func (*ClusterHealthService) Level Uses

func (s *ClusterHealthService) Level(level string) *ClusterHealthService

Level specifies the level of detail for returned information.

func (*ClusterHealthService) Local Uses

func (s *ClusterHealthService) Local(local bool) *ClusterHealthService

Local indicates whether to return local information. If it is true, we do not retrieve the state from master node (default: false).

func (*ClusterHealthService) MasterTimeout Uses

func (s *ClusterHealthService) MasterTimeout(masterTimeout string) *ClusterHealthService

MasterTimeout specifies an explicit operation timeout for connection to master node.

func (*ClusterHealthService) Timeout Uses

func (s *ClusterHealthService) Timeout(timeout string) *ClusterHealthService

Timeout specifies an explicit operation timeout.

func (*ClusterHealthService) Validate Uses

func (s *ClusterHealthService) Validate() error

Validate checks if the operation is valid.

func (*ClusterHealthService) WaitForActiveShards Uses

func (s *ClusterHealthService) WaitForActiveShards(waitForActiveShards int) *ClusterHealthService

WaitForActiveShards can be used to wait until the specified number of shards are active.

func (*ClusterHealthService) WaitForNodes Uses

func (s *ClusterHealthService) WaitForNodes(waitForNodes string) *ClusterHealthService

WaitForNodes can be used to wait until the specified number of nodes are available.

func (*ClusterHealthService) WaitForRelocatingShards Uses

func (s *ClusterHealthService) WaitForRelocatingShards(waitForRelocatingShards int) *ClusterHealthService

WaitForRelocatingShards can be used to wait until the specified number of relocating shards is finished.

func (*ClusterHealthService) WaitForStatus Uses

func (s *ClusterHealthService) WaitForStatus(waitForStatus string) *ClusterHealthService

WaitForStatus can be used to wait until the cluster is in a specific state. Valid values are: green, yellow, or red.

type ClusterStateMetadata Uses

type ClusterStateMetadata struct {
    Templates    map[string]interface{} `json:"templates"`
    Indices      map[string]interface{} `json:"indices"`
    Repositories map[string]interface{} `json:"repositories"`
}

type ClusterStateNode Uses

type ClusterStateNode struct {
    Name             string                 `json:"name"`
    TransportAddress string                 `json:"transport_address"`
    Attributes       map[string]interface{} `json:"attributes"`

    // TODO(oe) are these still valid?
    State          string  `json:"state"`
    Primary        bool    `json:"primary"`
    Node           string  `json:"node"`
    RelocatingNode *string `json:"relocating_node"`
    Shard          int     `json:"shard"`
    Index          string  `json:"index"`
}

type ClusterStateResponse Uses

type ClusterStateResponse struct {
    ClusterName  string                               `json:"cluster_name"`
    Version      int                                  `json:"version"`
    MasterNode   string                               `json:"master_node"`
    Blocks       map[string]interface{}               `json:"blocks"`
    Nodes        map[string]*ClusterStateNode         `json:"nodes"`
    Metadata     *ClusterStateMetadata                `json:"metadata"`
    RoutingTable map[string]*ClusterStateRoutingTable `json:"routing_table"`
    RoutingNodes *ClusterStateRoutingNode             `json:"routing_nodes"`
    Allocations  []interface{}                        `json:"allocations"`
    Customs      map[string]interface{}               `json:"customs"`
}

ClusterStateResponse is the response of ClusterStateService.Do.

type ClusterStateRoutingNode Uses

type ClusterStateRoutingNode struct {
    Unassigned []interface{}          `json:"unassigned"`
    Nodes      map[string]interface{} `json:"nodes"`
}

type ClusterStateRoutingTable Uses

type ClusterStateRoutingTable struct {
    Indices map[string]interface{} `json:"indices"`
}

type ClusterStateService Uses

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

ClusterStateService returns the state of the cluster. It is documented at http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.4/cluster-state.html.

Code:

client, err := elastic.NewClient()
if err != nil {
    panic(err)
}

// Get cluster state
res, err := client.ClusterState().Metric("version").Do()
if err != nil {
    panic(err)
}
fmt.Printf("Cluster %q has version %d", res.ClusterName, res.Version)

func NewClusterStateService Uses

func NewClusterStateService(client *Client) *ClusterStateService

NewClusterStateService creates a new ClusterStateService.

func (*ClusterStateService) Do Uses

func (s *ClusterStateService) Do() (*ClusterStateResponse, error)

Do executes the operation.

func (*ClusterStateService) FlatSettings Uses

func (s *ClusterStateService) FlatSettings(flatSettings bool) *ClusterStateService

FlatSettings indicates whether to return settings in flat format (default: false).

func (*ClusterStateService) Index Uses

func (s *ClusterStateService) Index(index string) *ClusterStateService

Index the name of the index. Use _all or an empty string to perform the operation on all indices.

func (*ClusterStateService) Indices Uses

func (s *ClusterStateService) Indices(indices ...string) *ClusterStateService

Indices is a list of index names. Use _all or an empty string to perform the operation on all indices.

func (*ClusterStateService) Local Uses

func (s *ClusterStateService) Local(local bool) *ClusterStateService

Local indicates whether to return local information. If it is true, we do not retrieve the state from master node (default: false).

func (*ClusterStateService) MasterTimeout Uses

func (s *ClusterStateService) MasterTimeout(masterTimeout string) *ClusterStateService

MasterTimeout specifies the timeout for connection to master.

func (*ClusterStateService) Metric Uses

func (s *ClusterStateService) Metric(metric string) *ClusterStateService

Metric limits the information returned to the specified metric. It can be one of: version, master_node, nodes, routing_table, metadata, blocks, or customs.

func (*ClusterStateService) Metrics Uses

func (s *ClusterStateService) Metrics(metrics ...string) *ClusterStateService

Metrics limits the information returned to the specified metrics. It can be any of: version, master_node, nodes, routing_table, metadata, blocks, or customs.

func (*ClusterStateService) Validate Uses

func (s *ClusterStateService) Validate() error

Validate checks if the operation is valid.

type ClusterStatsIndices Uses

type ClusterStatsIndices struct {
    Count       int                             `json:"count"`
    Shards      *ClusterStatsIndicesShards      `json:"shards"`
    Docs        *ClusterStatsIndicesDocs        `json:"docs"`
    Store       *ClusterStatsIndicesStore       `json:"store"`
    FieldData   *ClusterStatsIndicesFieldData   `json:"fielddata"`
    FilterCache *ClusterStatsIndicesFilterCache `json:"filter_cache"`
    IdCache     *ClusterStatsIndicesIdCache     `json:"id_cache"`
    Completion  *ClusterStatsIndicesCompletion  `json:"completion"`
    Segments    *ClusterStatsIndicesSegments    `json:"segments"`
    Percolate   *ClusterStatsIndicesPercolate   `json:"percolate"`
}

type ClusterStatsIndicesCompletion Uses

type ClusterStatsIndicesCompletion struct {
    Size        string `json:"size"` // e.g. "61.3kb"
    SizeInBytes int64  `json:"size_in_bytes"`
    Fields      map[string]struct {
        Size        string `json:"size"` // e.g. "61.3kb"
        SizeInBytes int64  `json:"size_in_bytes"`
    }   `json:"fields"`
}

type ClusterStatsIndicesDocs Uses

type ClusterStatsIndicesDocs struct {
    Count   int `json:"count"`
    Deleted int `json:"deleted"`
}

type ClusterStatsIndicesFieldData Uses

type ClusterStatsIndicesFieldData struct {
    MemorySize        string `json:"memory_size"` // e.g. "61.3kb"
    MemorySizeInBytes int64  `json:"memory_size_in_bytes"`
    Evictions         int64  `json:"evictions"`
    Fields            map[string]struct {
        MemorySize        string `json:"memory_size"` // e.g. "61.3kb"
        MemorySizeInBytes int64  `json:"memory_size_in_bytes"`
    }   `json:"fields"`
}

type ClusterStatsIndicesFilterCache Uses

type ClusterStatsIndicesFilterCache struct {
    MemorySize        string `json:"memory_size"` // e.g. "61.3kb"
    MemorySizeInBytes int64  `json:"memory_size_in_bytes"`
    Evictions         int64  `json:"evictions"`
}

type ClusterStatsIndicesIdCache Uses

type ClusterStatsIndicesIdCache struct {
    MemorySize        string `json:"memory_size"` // e.g. "61.3kb"
    MemorySizeInBytes int64  `json:"memory_size_in_bytes"`
}

type ClusterStatsIndicesPercolate Uses

type ClusterStatsIndicesPercolate struct {
    Total int64 `json:"total"`
    // TODO(oe) The JSON tag here is wrong as of ES 1.5.2 it seems
    Time              string `json:"get_time"` // e.g. "1s"
    TimeInBytes       int64  `json:"time_in_millis"`
    Current           int64  `json:"current"`
    MemorySize        string `json:"memory_size"` // e.g. "61.3kb"
    MemorySizeInBytes int64  `json:"memory_sitze_in_bytes"`
    Queries           int64  `json:"queries"`
}

type ClusterStatsIndicesSegments Uses

type ClusterStatsIndicesSegments struct {
    Count                       int64  `json:"count"`
    Memory                      string `json:"memory"` // e.g. "61.3kb"
    MemoryInBytes               int64  `json:"memory_in_bytes"`
    IndexWriterMemory           string `json:"index_writer_memory"` // e.g. "61.3kb"
    IndexWriterMemoryInBytes    int64  `json:"index_writer_memory_in_bytes"`
    IndexWriterMaxMemory        string `json:"index_writer_max_memory"` // e.g. "61.3kb"
    IndexWriterMaxMemoryInBytes int64  `json:"index_writer_max_memory_in_bytes"`
    VersionMapMemory            string `json:"version_map_memory"` // e.g. "61.3kb"
    VersionMapMemoryInBytes     int64  `json:"version_map_memory_in_bytes"`
    FixedBitSet                 string `json:"fixed_bit_set"` // e.g. "61.3kb"
    FixedBitSetInBytes          int64  `json:"fixed_bit_set_memory_in_bytes"`
}

type ClusterStatsIndicesShards Uses

type ClusterStatsIndicesShards struct {
    Total       int                             `json:"total"`
    Primaries   int                             `json:"primaries"`
    Replication float64                         `json:"replication"`
    Index       *ClusterStatsIndicesShardsIndex `json:"index"`
}

type ClusterStatsIndicesShardsIndex Uses

type ClusterStatsIndicesShardsIndex struct {
    Shards      *ClusterStatsIndicesShardsIndexIntMinMax     `json:"shards"`
    Primaries   *ClusterStatsIndicesShardsIndexIntMinMax     `json:"primaries"`
    Replication *ClusterStatsIndicesShardsIndexFloat64MinMax `json:"replication"`
}

type ClusterStatsIndicesShardsIndexFloat64MinMax Uses

type ClusterStatsIndicesShardsIndexFloat64MinMax struct {
    Min float64 `json:"min"`
    Max float64 `json:"max"`
    Avg float64 `json:"avg"`
}

type ClusterStatsIndicesShardsIndexIntMinMax Uses

type ClusterStatsIndicesShardsIndexIntMinMax struct {
    Min int     `json:"min"`
    Max int     `json:"max"`
    Avg float64 `json:"avg"`
}

type ClusterStatsIndicesStore Uses

type ClusterStatsIndicesStore struct {
    Size                 string `json:"size"` // e.g. "5.3gb"
    SizeInBytes          int64  `json:"size_in_bytes"`
    ThrottleTime         string `json:"throttle_time"` // e.g. "0s"
    ThrottleTimeInMillis int64  `json:"throttle_time_in_millis"`
}

type ClusterStatsNodes Uses

type ClusterStatsNodes struct {
    Count    *ClusterStatsNodesCount        `json:"count"`
    Versions []string                       `json:"versions"`
    OS       *ClusterStatsNodesOsStats      `json:"os"`
    Process  *ClusterStatsNodesProcessStats `json:"process"`
    JVM      *ClusterStatsNodesJvmStats     `json:"jvm"`
    FS       *ClusterStatsNodesFsStats      `json:"fs"`
    Plugins  []*ClusterStatsNodesPlugin     `json:"plugins"`
}

type ClusterStatsNodesCount Uses

type ClusterStatsNodesCount struct {
    Total      int `json:"total"`
    MasterOnly int `json:"master_only"`
    DataOnly   int `json:"data_only"`
    MasterData int `json:"master_data"`
    Client     int `json:"client"`
}

type ClusterStatsNodesFsStats Uses

type ClusterStatsNodesFsStats struct {
    Path                 string `json:"path"`
    Mount                string `json:"mount"`
    Dev                  string `json:"dev"`
    Total                string `json:"total"` // e.g. "930.7gb"`
    TotalInBytes         int64  `json:"total_in_bytes"`
    Free                 string `json:"free"` // e.g. "930.7gb"`
    FreeInBytes          int64  `json:"free_in_bytes"`
    Available            string `json:"available"` // e.g. "930.7gb"`
    AvailableInBytes     int64  `json:"available_in_bytes"`
    DiskReads            int64  `json:"disk_reads"`
    DiskWrites           int64  `json:"disk_writes"`
    DiskIOOp             int64  `json:"disk_io_op"`
    DiskReadSize         string `json:"disk_read_size"` // e.g. "0b"`
    DiskReadSizeInBytes  int64  `json:"disk_read_size_in_bytes"`
    DiskWriteSize        string `json:"disk_write_size"` // e.g. "0b"`
    DiskWriteSizeInBytes int64  `json:"disk_write_size_in_bytes"`
    DiskIOSize           string `json:"disk_io_size"` // e.g. "0b"`
    DiskIOSizeInBytes    int64  `json:"disk_io_size_in_bytes"`
    DiskQueue            string `json:"disk_queue"`
    DiskServiceTime      string `json:"disk_service_time"`
}

type ClusterStatsNodesJvmStats Uses

type ClusterStatsNodesJvmStats struct {
    MaxUptime         string                              `json:"max_uptime"` // e.g. "5h"
    MaxUptimeInMillis int64                               `json:"max_uptime_in_millis"`
    Versions          []*ClusterStatsNodesJvmStatsVersion `json:"versions"`
    Mem               *ClusterStatsNodesJvmStatsMem       `json:"mem"`
    Threads           int64                               `json:"threads"`
}

type ClusterStatsNodesJvmStatsMem Uses

type ClusterStatsNodesJvmStatsMem struct {
    HeapUsed        string `json:"heap_used"`
    HeapUsedInBytes int64  `json:"heap_used_in_bytes"`
    HeapMax         string `json:"heap_max"`
    HeapMaxInBytes  int64  `json:"heap_max_in_bytes"`
}

type ClusterStatsNodesJvmStatsVersion Uses

type ClusterStatsNodesJvmStatsVersion struct {
    Version   string `json:"version"`    // e.g. "1.8.0_45"
    VMName    string `json:"vm_name"`    // e.g. "Java HotSpot(TM) 64-Bit Server VM"
    VMVersion string `json:"vm_version"` // e.g. "25.45-b02"
    VMVendor  string `json:"vm_vendor"`  // e.g. "Oracle Corporation"
    Count     int    `json:"count"`
}

type ClusterStatsNodesOsStats Uses

type ClusterStatsNodesOsStats struct {
    AvailableProcessors int                            `json:"available_processors"`
    Mem                 *ClusterStatsNodesOsStatsMem   `json:"mem"`
    CPU                 []*ClusterStatsNodesOsStatsCPU `json:"cpu"`
}

type ClusterStatsNodesOsStatsCPU Uses

type ClusterStatsNodesOsStatsCPU struct {
    Vendor           string `json:"vendor"`
    Model            string `json:"model"`
    MHz              int    `json:"mhz"`
    TotalCores       int    `json:"total_cores"`
    TotalSockets     int    `json:"total_sockets"`
    CoresPerSocket   int    `json:"cores_per_socket"`
    CacheSize        string `json:"cache_size"` // e.g. "256b"
    CacheSizeInBytes int64  `json:"cache_size_in_bytes"`
    Count            int    `json:"count"`
}

type ClusterStatsNodesOsStatsMem Uses

type ClusterStatsNodesOsStatsMem struct {
    Total        string `json:"total"` // e.g. "16gb"
    TotalInBytes int64  `json:"total_in_bytes"`
}

type ClusterStatsNodesPlugin Uses

type ClusterStatsNodesPlugin struct {
    Name        string `json:"name"`
    Version     string `json:"version"`
    Description string `json:"description"`
    URL         string `json:"url"`
    JVM         bool   `json:"jvm"`
    Site        bool   `json:"site"`
}

type ClusterStatsNodesProcessStats Uses

type ClusterStatsNodesProcessStats struct {
    CPU                 *ClusterStatsNodesProcessStatsCPU                 `json:"cpu"`
    OpenFileDescriptors *ClusterStatsNodesProcessStatsOpenFileDescriptors `json:"open_file_descriptors"`
}

type ClusterStatsNodesProcessStatsCPU Uses

type ClusterStatsNodesProcessStatsCPU struct {
    Percent float64 `json:"percent"`
}

type ClusterStatsNodesProcessStatsOpenFileDescriptors Uses

type ClusterStatsNodesProcessStatsOpenFileDescriptors struct {
    Min int64 `json:"min"`
    Max int64 `json:"max"`
    Avg int64 `json:"avg"`
}

type ClusterStatsResponse Uses

type ClusterStatsResponse struct {
    Timestamp   int64                `json:"timestamp"`
    ClusterName string               `json:"cluster_name"`
    ClusterUUID string               `json:"uuid"`
    Status      string               `json:"status"`
    Indices     *ClusterStatsIndices `json:"indices"`
    Nodes       *ClusterStatsNodes   `json:"nodes"`
}

ClusterStatsResponse is the response of ClusterStatsService.Do.

type ClusterStatsService Uses

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

ClusterStatsService is documented at http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.4/cluster-stats.html.

func NewClusterStatsService Uses

func NewClusterStatsService(client *Client) *ClusterStatsService

NewClusterStatsService creates a new ClusterStatsService.

func (*ClusterStatsService) Do Uses

func (s *ClusterStatsService) Do() (*ClusterStatsResponse, error)

Do executes the operation.

func (*ClusterStatsService) FlatSettings Uses

func (s *ClusterStatsService) FlatSettings(flatSettings bool) *ClusterStatsService

FlatSettings is documented as: Return settings in flat format (default: false).

func (*ClusterStatsService) Human Uses

func (s *ClusterStatsService) Human(human bool) *ClusterStatsService

Human is documented as: Whether to return time and byte values in human-readable format..

func (*ClusterStatsService) NodeId Uses

func (s *ClusterStatsService) NodeId(nodeId []string) *ClusterStatsService

NodeId is documented as: A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes.

func (*ClusterStatsService) Pretty Uses

func (s *ClusterStatsService) Pretty(pretty bool) *ClusterStatsService

Pretty indicates that the JSON response be indented and human readable.

func (*ClusterStatsService) Validate Uses

func (s *ClusterStatsService) Validate() error

Validate checks if the operation is valid.

type CommonQuery Uses

type CommonQuery struct {
    Query
    // contains filtered or unexported fields
}

The common terms query is a modern alternative to stopwords which improves the precision and recall of search results (by taking stopwords into account), without sacrificing performance. For more details, see: http://www.elasticsearch.org/guide/reference/query-dsl/common-terms-query/

func NewCommonQuery Uses

func NewCommonQuery(name string, query string) CommonQuery

Creates a new common query.

func (*CommonQuery) Analyzer Uses

func (q *CommonQuery) Analyzer(analyzer string) *CommonQuery

func (*CommonQuery) Boost Uses

func (q *CommonQuery) Boost(boost float64) *CommonQuery

func (*CommonQuery) CutoffFrequency Uses

func (q *CommonQuery) CutoffFrequency(f float64) *CommonQuery

func (*CommonQuery) DisableCoords Uses

func (q *CommonQuery) DisableCoords(disable bool) *CommonQuery

func (*CommonQuery) HighFreq Uses

func (q *CommonQuery) HighFreq(f float64) *CommonQuery

func (*CommonQuery) HighFreqMinMatch Uses

func (q *CommonQuery) HighFreqMinMatch(min interface{}) *CommonQuery

func (*CommonQuery) HighFreqOperator Uses

func (q *CommonQuery) HighFreqOperator(op string) *CommonQuery

func (*CommonQuery) LowFreq Uses

func (q *CommonQuery) LowFreq(f float64) *CommonQuery

func (*CommonQuery) LowFreqMinMatch Uses

func (q *CommonQuery) LowFreqMinMatch(min interface{}) *CommonQuery

func (*CommonQuery) LowFreqOperator Uses

func (q *CommonQuery) LowFreqOperator(op string) *CommonQuery

func (CommonQuery) Source Uses

func (q CommonQuery) Source() interface{}

Creates the query source for the common query.

type CompletionSuggester Uses

type CompletionSuggester struct {
    Suggester
    // contains filtered or unexported fields
}

CompletionSuggester is a fast suggester for e.g. type-ahead completion. See http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-suggesters-completion.html for more details.

func NewCompletionSuggester Uses

func NewCompletionSuggester(name string) CompletionSuggester

Creates a new completion suggester.

func (CompletionSuggester) Analyzer Uses

func (q CompletionSuggester) Analyzer(analyzer string) CompletionSuggester

func (CompletionSuggester) ContextQueries Uses

func (q CompletionSuggester) ContextQueries(queries ...SuggesterContextQuery) CompletionSuggester

func (CompletionSuggester) ContextQuery Uses

func (q CompletionSuggester) ContextQuery(query SuggesterContextQuery) CompletionSuggester

func (CompletionSuggester) Field Uses

func (q CompletionSuggester) Field(field string) CompletionSuggester

func (CompletionSuggester) Name Uses

func (q CompletionSuggester) Name() string

func (CompletionSuggester) ShardSize Uses

func (q CompletionSuggester) ShardSize(shardSize int) CompletionSuggester

func (CompletionSuggester) Size Uses

func (q CompletionSuggester) Size(size int) CompletionSuggester

func (CompletionSuggester) Source Uses

func (q CompletionSuggester) Source(includeName bool) interface{}

Creates the source for the completion suggester.

func (CompletionSuggester) Text Uses

func (q CompletionSuggester) Text(text string) CompletionSuggester

type ConstantScoreQuery Uses

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

ConstantScoreQuery wraps a filter or another query and simply returns a constant score equal to the query boost for every document in the filter.

For more details, see https://www.elastic.co/guide/en/elasticsearch/reference/1.7/query-dsl-constant-score-query.html

func NewConstantScoreQuery Uses

func NewConstantScoreQuery() ConstantScoreQuery

NewConstantScoreQuery creates a new constant score query.

func (ConstantScoreQuery) Boost Uses

func (q ConstantScoreQuery) Boost(boost float64) ConstantScoreQuery

Boost sets the boost for this query. Documents matching this query will (in addition to the normal weightings) have their score multiplied by the boost provided.

func (ConstantScoreQuery) Filter Uses

func (q ConstantScoreQuery) Filter(filter Filter) ConstantScoreQuery

Filter to wrap in this constant score query.

func (ConstantScoreQuery) Query Uses

func (q ConstantScoreQuery) Query(query Query) ConstantScoreQuery

Query to wrap in this constant score query.

func (ConstantScoreQuery) Source Uses

func (q ConstantScoreQuery) Source() interface{}

Source returns JSON for the function score query.

type CountResponse Uses

type CountResponse struct {
    Count  int64      `json:"count"`
    Shards shardsInfo `json:"_shards,omitempty"`
}

CountResponse is the response of using the Count API.

type CountService Uses

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

CountService is a convenient service for determining the number of documents in an index. Use SearchService with a SearchType of count for counting with queries etc.

func NewCountService Uses

func NewCountService(client *Client) *CountService

NewCountService creates a new CountService.

func (*CountService) AllowNoIndices Uses

func (s *CountService) AllowNoIndices(allowNoIndices bool) *CountService

AllowNoIndices indicates whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes "_all" string or when no indices have been specified).

func (*CountService) AnalyzeWildcard Uses

func (s *CountService) AnalyzeWildcard(analyzeWildcard bool) *CountService

AnalyzeWildcard specifies whether wildcard and prefix queries should be analyzed (default: false).

func (*CountService) Analyzer Uses

func (s *CountService) Analyzer(analyzer string) *CountService

Analyzer specifies the analyzer to use for the query string.

func (*CountService) BodyJson Uses

func (s *CountService) BodyJson(body interface{}) *CountService

BodyJson specifies the query to restrict the results specified with the Query DSL (optional). The interface{} will be serialized to a JSON document, so use a map[string]interface{}.

func (*CountService) BodyString Uses

func (s *CountService) BodyString(body string) *CountService

Body specifies a query to restrict the results specified with the Query DSL (optional).

func (*CountService) DefaultOperator Uses

func (s *CountService) DefaultOperator(defaultOperator string) *CountService

DefaultOperator specifies the default operator for query string query (AND or OR).

func (*CountService) Df Uses

func (s *CountService) Df(df string) *CountService

Df specifies the field to use as default where no field prefix is given in the query string.

func (*CountService) Do Uses

func (s *CountService) Do() (int64, error)

Do executes the operation.

func (*CountService) ExpandWildcards Uses

func (s *CountService) ExpandWildcards(expandWildcards string) *CountService

ExpandWildcards indicates whether to expand wildcard expression to concrete indices that are open, closed or both.

func (*CountService) IgnoreUnavailable Uses

func (s *CountService) IgnoreUnavailable(ignoreUnavailable bool) *CountService

IgnoreUnavailable indicates whether specified concrete indices should be ignored when unavailable (missing or closed).

func (*CountService) Index Uses

func (s *CountService) Index(index string) *CountService

Index sets the name of the index to use to restrict the results.

func (*CountService) Indices Uses

func (s *CountService) Indices(indices ...string) *CountService

Indices sets the names of the indices to restrict the results.

func (*CountService) Lenient Uses

func (s *CountService) Lenient(lenient bool) *CountService

Lenient specifies whether format-based query failures (such as providing text to a numeric field) should be ignored.

func (*CountService) LowercaseExpandedTerms Uses

func (s *CountService) LowercaseExpandedTerms(lowercaseExpandedTerms bool) *CountService

LowercaseExpandedTerms specifies whether query terms should be lowercased.

func (*CountService) MinScore Uses

func (s *CountService) MinScore(minScore interface{}) *CountService

MinScore indicates to include only documents with a specific `_score` value in the result.

func (*CountService) Preference Uses

func (s *CountService) Preference(preference string) *CountService

Preference specifies the node or shard the operation should be performed on (default: random).

func (*CountService) Pretty Uses

func (s *CountService) Pretty(pretty bool) *CountService

Pretty indicates that the JSON response be indented and human readable.

func (*CountService) Q Uses

func (s *CountService) Q(q string) *CountService

Q in the Lucene query string syntax. You can also use Query to pass a Query struct.

func (*CountService) Query Uses

func (s *CountService) Query(query Query) *CountService

Query specifies the query to pass. You can also pass a query string with Q.

func (*CountService) Routing Uses

func (s *CountService) Routing(routing string) *CountService

Routing specifies the routing value.

func (*CountService) Type Uses

func (s *CountService) Type(typ string) *CountService

Type sets the type to use to restrict the results.

func (*CountService) Types Uses

func (s *CountService) Types(types ...string) *CountService

Types sets the types to use to restrict the results.

func (*CountService) Validate Uses

func (s *CountService) Validate() error

Validate checks if the operation is valid.

type CreateIndexResult Uses

type CreateIndexResult struct {
    Acknowledged bool `json:"acknowledged"`
}

CreateIndexResult is the outcome of creating a new index.

type CreateIndexService Uses

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

CreateIndexService creates a new index.

Code:

// Get a client to the local Elasticsearch instance.
client, err := elastic.NewClient()
if err != nil {
    // Handle error
    panic(err)
}
// Create a new index.
createIndex, err := client.CreateIndex("twitter").Do()
if err != nil {
    // Handle error
    panic(err)
}
if !createIndex.Acknowledged {
    // Not acknowledged
}

func NewCreateIndexService Uses

func NewCreateIndexService(client *Client) *CreateIndexService

NewCreateIndexService returns a new CreateIndexService.

func (*CreateIndexService) Body Uses

func (b *CreateIndexService) Body(body string) *CreateIndexService

Body specifies the configuration of the index as a string. It is an alias for BodyString.

func (*CreateIndexService) BodyJson Uses

func (b *CreateIndexService) BodyJson(body interface{}) *CreateIndexService

BodyJson specifies the configuration of the index. The interface{} will be serializes as a JSON document, so use a map[string]interface{}.

func (*CreateIndexService) BodyString Uses

func (b *CreateIndexService) BodyString(body string) *CreateIndexService

BodyString specifies the configuration of the index as a string.

func (*CreateIndexService) Do Uses

func (b *CreateIndexService) Do() (*CreateIndexResult, error)

Do executes the operation.

func (*CreateIndexService) Index Uses

func (b *CreateIndexService) Index(index string) *CreateIndexService

Index is the name of the index to create.

func (*CreateIndexService) MasterTimeout Uses

func (s *CreateIndexService) MasterTimeout(masterTimeout string) *CreateIndexService

MasterTimeout specifies the timeout for connection to master.

func (*CreateIndexService) Pretty Uses

func (b *CreateIndexService) Pretty(pretty bool) *CreateIndexService

Pretty indicates that the JSON response be indented and human readable.

func (*CreateIndexService) Timeout Uses

func (s *CreateIndexService) Timeout(timeout string) *CreateIndexService

Timeout the explicit operation timeout, e.g. "5s".

type CustomFiltersScoreQuery Uses

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

A custom_filters_score query allows to execute a query, and if the hit matches a provided filter (ordered), use either a boost or a script associated with it to compute the score.

For more details, see: http://www.elasticsearch.org/guide/reference/query-dsl/custom-filters-score-query/

func NewCustomFiltersScoreQuery Uses

func NewCustomFiltersScoreQuery() CustomFiltersScoreQuery

Creates a new custom_filters_score query.

func (CustomFiltersScoreQuery) Filter Uses

func (q CustomFiltersScoreQuery) Filter(filter Filter) CustomFiltersScoreQuery

func (CustomFiltersScoreQuery) MaxBoost Uses

func (q CustomFiltersScoreQuery) MaxBoost(maxBoost float32) CustomFiltersScoreQuery

func (CustomFiltersScoreQuery) Query Uses

func (q CustomFiltersScoreQuery) Query(query Query) CustomFiltersScoreQuery

func (CustomFiltersScoreQuery) ScoreMode Uses

func (q CustomFiltersScoreQuery) ScoreMode(scoreMode string) CustomFiltersScoreQuery

func (CustomFiltersScoreQuery) Script Uses

func (q CustomFiltersScoreQuery) Script(script string) CustomFiltersScoreQuery

func (CustomFiltersScoreQuery) Source Uses

func (q CustomFiltersScoreQuery) Source() interface{}

Creates the query source for the custom_filters_score query.

type CustomScoreQuery Uses

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

custom_score query allows to wrap another query and customize the scoring of it optionally with a computation derived from other field values in the doc (numeric ones) using script expression.

For more details, see: http://www.elasticsearch.org/guide/reference/query-dsl/custom-score-query/

func NewCustomScoreQuery Uses

func NewCustomScoreQuery() CustomScoreQuery

Creates a new custom_score query.

func (CustomScoreQuery) Boost Uses

func (q CustomScoreQuery) Boost(boost float32) CustomScoreQuery

func (CustomScoreQuery) Filter Uses

func (q CustomScoreQuery) Filter(filter Filter) CustomScoreQuery

func (CustomScoreQuery) Lang Uses

func (q CustomScoreQuery) Lang(lang string) CustomScoreQuery

func (CustomScoreQuery) Param Uses

func (q CustomScoreQuery) Param(name string, value interface{}) CustomScoreQuery

func (CustomScoreQuery) Params Uses

func (q CustomScoreQuery) Params(params map[string]interface{}) CustomScoreQuery

func (CustomScoreQuery) Query Uses

func (q CustomScoreQuery) Query(query Query) CustomScoreQuery

func (CustomScoreQuery) Script Uses

func (q CustomScoreQuery) Script(script string) CustomScoreQuery

func (CustomScoreQuery) Source Uses

func (q CustomScoreQuery) Source() interface{}

Creates the query source for the custom_fscore query.

type DateHistogramAggregation Uses

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

DateHistogramAggregation is a multi-bucket aggregation similar to the histogram except it can only be applied on date values. See: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-bucket-datehistogram-aggregation.html

func NewDateHistogramAggregation Uses

func NewDateHistogramAggregation() DateHistogramAggregation

func (DateHistogramAggregation) ExtendedBoundsMax Uses

func (a DateHistogramAggregation) ExtendedBoundsMax(max interface{}) DateHistogramAggregation

ExtendedBoundsMax accepts int, int64, string, or time.Time values.

func (DateHistogramAggregation) ExtendedBoundsMin Uses

func (a DateHistogramAggregation) ExtendedBoundsMin(min interface{}) DateHistogramAggregation

ExtendedBoundsMin accepts int, int64, string, or time.Time values.

func (DateHistogramAggregation) Factor Uses

func (a DateHistogramAggregation) Factor(factor float32) DateHistogramAggregation

func (DateHistogramAggregation) Field Uses

func (a DateHistogramAggregation) Field(field string) DateHistogramAggregation

func (DateHistogramAggregation) Format Uses

func (a DateHistogramAggregation) Format(format string) DateHistogramAggregation

func (DateHistogramAggregation) Interval Uses

func (a DateHistogramAggregation) Interval(interval string) DateHistogramAggregation

Allowed values are: "year", "quarter", "month", "week", "day", "hour", "minute". It also supports time settings like "1.5h" (up to "w" for weeks).

func (DateHistogramAggregation) Lang Uses

func (a DateHistogramAggregation) Lang(lang string) DateHistogramAggregation

func (DateHistogramAggregation) MinDocCount Uses

func (a DateHistogramAggregation) MinDocCount(minDocCount int64) DateHistogramAggregation

func (DateHistogramAggregation) Order Uses

func (a DateHistogramAggregation) Order(order string, asc bool) DateHistogramAggregation

Order specifies the sort order. Valid values for order are: "_key", "_count", a sub-aggregation name, or a sub-aggregation name with a metric.

func (DateHistogramAggregation) OrderByAggregation Uses

func (a DateHistogramAggregation) OrderByAggregation(aggName string, asc bool) DateHistogramAggregation

OrderByAggregation creates a bucket ordering strategy which sorts buckets based on a single-valued calc get.

func (DateHistogramAggregation) OrderByAggregationAndMetric Uses

func (a DateHistogramAggregation) OrderByAggregationAndMetric(aggName, metric string, asc bool) DateHistogramAggregation

OrderByAggregationAndMetric creates a bucket ordering strategy which sorts buckets based on a multi-valued calc get.

func (DateHistogramAggregation) OrderByCount Uses

func (a DateHistogramAggregation) OrderByCount(asc bool) DateHistogramAggregation

func (DateHistogramAggregation) OrderByCountAsc Uses

func (a DateHistogramAggregation) OrderByCountAsc() DateHistogramAggregation

func (DateHistogramAggregation) OrderByCountDesc Uses

func (a DateHistogramAggregation) OrderByCountDesc() DateHistogramAggregation

func (DateHistogramAggregation) OrderByKey Uses

func (a DateHistogramAggregation) OrderByKey(asc bool) DateHistogramAggregation

func (DateHistogramAggregation) OrderByKeyAsc Uses

func (a DateHistogramAggregation) OrderByKeyAsc() DateHistogramAggregation

func (DateHistogramAggregation) OrderByKeyDesc Uses

func (a DateHistogramAggregation) OrderByKeyDesc() DateHistogramAggregation

func (DateHistogramAggregation) Param Uses

func (a DateHistogramAggregation) Param(name string, value interface{}) DateHistogramAggregation

func (DateHistogramAggregation) PostOffset Uses

func (a DateHistogramAggregation) PostOffset(postOffset int64) DateHistogramAggregation

func (DateHistogramAggregation) PostZone Uses

func (a DateHistogramAggregation) PostZone(postZone string) DateHistogramAggregation

func (DateHistogramAggregation) PreOffset Uses

func (a DateHistogramAggregation) PreOffset(preOffset int64) DateHistogramAggregation

func (DateHistogramAggregation) PreZone Uses

func (a DateHistogramAggregation) PreZone(preZone string) DateHistogramAggregation

func (DateHistogramAggregation) PreZoneAdjustLargeInterval Uses

func (a DateHistogramAggregation) PreZoneAdjustLargeInterval(preZoneAdjustLargeInterval bool) DateHistogramAggregation

func (DateHistogramAggregation) Script Uses

func (a DateHistogramAggregation) Script(script string) DateHistogramAggregation

func (DateHistogramAggregation) ScriptFile Uses

func (a DateHistogramAggregation) ScriptFile(scriptFile string) DateHistogramAggregation

func (DateHistogramAggregation) Source Uses

func (a DateHistogramAggregation) Source() interface{}

func (DateHistogramAggregation) SubAggregation Uses

func (a DateHistogramAggregation) SubAggregation(name string, subAggregation Aggregation) DateHistogramAggregation

type DateHistogramFacet Uses

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

A specific histogram facet that can work with date field types enhancing it over the regular histogram facet. See: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-facets-date-histogram-facet.html

func NewDateHistogramFacet Uses

func NewDateHistogramFacet() DateHistogramFacet

func (DateHistogramFacet) Comparator Uses

func (f DateHistogramFacet) Comparator(comparator string) DateHistogramFacet

func (DateHistogramFacet) FacetFilter Uses

func (f DateHistogramFacet) FacetFilter(filter Facet) DateHistogramFacet

func (DateHistogramFacet) Factor Uses

func (f DateHistogramFacet) Factor(factor float32) DateHistogramFacet

func (DateHistogramFacet) Field Uses

func (f DateHistogramFacet) Field(field string) DateHistogramFacet

func (DateHistogramFacet) Global Uses

func (f DateHistogramFacet) Global(global bool) DateHistogramFacet

func (DateHistogramFacet) Interval Uses

func (f DateHistogramFacet) Interval(interval string) DateHistogramFacet

Allowed values are: "year", "quarter", "month", "week", "day", "hour", "minute". It also supports time settings like "1.5h" (up to "w" for weeks).

func (DateHistogramFacet) KeyField Uses

func (f DateHistogramFacet) KeyField(keyField string) DateHistogramFacet

func (DateHistogramFacet) Lang Uses

func (f DateHistogramFacet) Lang(lang string) DateHistogramFacet

func (DateHistogramFacet) Mode Uses

func (f DateHistogramFacet) Mode(mode string) DateHistogramFacet

func (DateHistogramFacet) Nested Uses

func (f DateHistogramFacet) Nested(nested string) DateHistogramFacet

func (DateHistogramFacet) Param Uses

func (f DateHistogramFacet) Param(name string, value interface{}) DateHistogramFacet

func (DateHistogramFacet) PostOffset Uses

func (f DateHistogramFacet) PostOffset(postOffset string) DateHistogramFacet

func (DateHistogramFacet) PostZone Uses

func (f DateHistogramFacet) PostZone(postZone string) DateHistogramFacet

func (DateHistogramFacet) PreOffset Uses

func (f DateHistogramFacet) PreOffset(preOffset string) DateHistogramFacet

func (DateHistogramFacet) PreZone Uses

func (f DateHistogramFacet) PreZone(preZone string) DateHistogramFacet

func (DateHistogramFacet) PreZoneAdjustLargeInterval Uses

func (f DateHistogramFacet) PreZoneAdjustLargeInterval(preZoneAdjustLargeInterval bool) DateHistogramFacet

func (DateHistogramFacet) Source Uses

func (f DateHistogramFacet) Source() interface{}

func (DateHistogramFacet) ValueField Uses

func (f DateHistogramFacet) ValueField(valueField string) DateHistogramFacet

func (DateHistogramFacet) ValueScript Uses

func (f DateHistogramFacet) ValueScript(valueScript string) DateHistogramFacet

type DateRangeAggregation Uses

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

DateRangeAggregation is a range aggregation that is dedicated for date values. The main difference between this aggregation and the normal range aggregation is that the from and to values can be expressed in Date Math expressions, and it is also possible to specify a date format by which the from and to response fields will be returned. Note that this aggregration includes the from value and excludes the to value for each range. See: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-bucket-daterange-aggregation.html

func NewDateRangeAggregation Uses

func NewDateRangeAggregation() DateRangeAggregation

func (DateRangeAggregation) AddRange Uses

func (a DateRangeAggregation) AddRange(from, to interface{}) DateRangeAggregation

func (DateRangeAggregation) AddRangeWithKey Uses

func (a DateRangeAggregation) AddRangeWithKey(key string, from, to interface{}) DateRangeAggregation

func (DateRangeAggregation) AddUnboundedFrom Uses

func (a DateRangeAggregation) AddUnboundedFrom(to interface{}) DateRangeAggregation

func (DateRangeAggregation) AddUnboundedFromWithKey Uses

func (a DateRangeAggregation) AddUnboundedFromWithKey(key string, to interface{}) DateRangeAggregation

func (DateRangeAggregation) AddUnboundedTo Uses

func (a DateRangeAggregation) AddUnboundedTo(from interface{}) DateRangeAggregation

func (DateRangeAggregation) AddUnboundedToWithKey Uses

func (a DateRangeAggregation) AddUnboundedToWithKey(key string, from interface{}) DateRangeAggregation

func (DateRangeAggregation) Between Uses

func (a DateRangeAggregation) Between(from, to interface{}) DateRangeAggregation

func (DateRangeAggregation) BetweenWithKey Uses

func (a DateRangeAggregation) BetweenWithKey(key string, from, to interface{}) DateRangeAggregation

func (DateRangeAggregation) Field Uses

func (a DateRangeAggregation) Field(field string) DateRangeAggregation

func (DateRangeAggregation) Format Uses

func (a DateRangeAggregation) Format(format string) DateRangeAggregation

func (DateRangeAggregation) Gt Uses

func (a DateRangeAggregation) Gt(from interface{}) DateRangeAggregation

func (DateRangeAggregation) GtWithKey Uses

func (a DateRangeAggregation) GtWithKey(key string, from interface{}) DateRangeAggregation

func (DateRangeAggregation) Keyed Uses

func (a DateRangeAggregation) Keyed(keyed bool) DateRangeAggregation

func (DateRangeAggregation) Lang Uses

func (a DateRangeAggregation) Lang(lang string) DateRangeAggregation

func (DateRangeAggregation) Lt Uses

func (a DateRangeAggregation) Lt(to interface{}) DateRangeAggregation

func (DateRangeAggregation) LtWithKey Uses

func (a DateRangeAggregation) LtWithKey(key string, to interface{}) DateRangeAggregation

func (DateRangeAggregation) Param Uses

func (a DateRangeAggregation) Param(name string, value interface{}) DateRangeAggregation

func (DateRangeAggregation) Script Uses

func (a DateRangeAggregation) Script(script string) DateRangeAggregation

func (DateRangeAggregation) ScriptFile Uses

func (a DateRangeAggregation) ScriptFile(scriptFile string) DateRangeAggregation

func (DateRangeAggregation) Source Uses

func (a DateRangeAggregation) Source() interface{}

func (DateRangeAggregation) SubAggregation Uses

func (a DateRangeAggregation) SubAggregation(name string, subAggregation Aggregation) DateRangeAggregation

func (DateRangeAggregation) Unmapped Uses

func (a DateRangeAggregation) Unmapped(unmapped bool) DateRangeAggregation

type DateRangeAggregationEntry Uses

type DateRangeAggregationEntry struct {
    Key  string
    From interface{}
    To   interface{}
}

type Decoder Uses

type Decoder interface {
    Decode(data []byte, v interface{}) error
}

Decoder is used to decode responses from Elasticsearch. Users of elastic can implement their own marshaler for advanced purposes and set them per Client (see SetDecoder). If none is specified, DefaultDecoder is used.

type DefaultDecoder Uses

type DefaultDecoder struct{}

DefaultDecoder uses json.Unmarshal from the Go standard library to decode JSON data.

func (*DefaultDecoder) Decode Uses

func (u *DefaultDecoder) Decode(data []byte, v interface{}) error

Decode decodes with json.Unmarshal from the Go standard library.

type DeleteByQueryResult Uses

type DeleteByQueryResult struct {
    Indices map[string]IndexDeleteByQueryResult `json:"_indices"`
}

DeleteByQueryResult is the outcome of executing Do with DeleteByQueryService.

type DeleteByQueryService Uses

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

DeleteByQueryService deletes documents that match a query. See http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/docs-delete-by-query.html.

func NewDeleteByQueryService Uses

func NewDeleteByQueryService(client *Client) *DeleteByQueryService

NewDeleteByQueryService creates a new DeleteByQueryService. You typically use the client's DeleteByQuery to get a reference to the service.

func (*DeleteByQueryService) AllowNoIndices Uses

func (s *DeleteByQueryService) AllowNoIndices(allow bool) *DeleteByQueryService

AllowNoIndices indicates whether to ignore if a wildcard indices expression resolves into no concrete indices (including the _all string or when no indices have been specified).

func (*DeleteByQueryService) Analyzer Uses

func (s *DeleteByQueryService) Analyzer(analyzer string) *DeleteByQueryService

Analyzer to use for the query string.

func (*DeleteByQueryService) Consistency Uses

func (s *DeleteByQueryService) Consistency(consistency string) *DeleteByQueryService

Consistency represents the specific write consistency setting for the operation. It can be one, quorum, or all.

func (*DeleteByQueryService) DF Uses

func (s *DeleteByQueryService) DF(defaultField string) *DeleteByQueryService

DF is the field to use as default where no field prefix is given in the query string.

func (*DeleteByQueryService) DefaultField Uses

func (s *DeleteByQueryService) DefaultField(defaultField string) *DeleteByQueryService

DefaultField is the field to use as default where no field prefix is given in the query string. It is an alias to the DF func.

func (*DeleteByQueryService) DefaultOperator Uses

func (s *DeleteByQueryService) DefaultOperator(defaultOperator string) *DeleteByQueryService

DefaultOperator for query string query (AND or OR).

func (*DeleteByQueryService) Do Uses

func (s *DeleteByQueryService) Do() (*DeleteByQueryResult, error)

Do executes the delete-by-query operation.

func (*DeleteByQueryService) ExpandWildcards Uses

func (s *DeleteByQueryService) ExpandWildcards(expand string) *DeleteByQueryService

ExpandWildcards indicates whether to expand wildcard expression to concrete indices that are open, closed or both. It can be "open" or "closed".

func (*DeleteByQueryService) IgnoreUnavailable Uses

func (s *DeleteByQueryService) IgnoreUnavailable(ignore bool) *DeleteByQueryService

IgnoreUnavailable indicates whether specified concrete indices should be ignored when unavailable (missing or closed).

func (*DeleteByQueryService) Index Uses

func (s *DeleteByQueryService) Index(index string) *DeleteByQueryService

Index limits the delete-by-query to a single index. You can use _all to perform the operation on all indices.

func (*DeleteByQueryService) Indices Uses

func (s *DeleteByQueryService) Indices(indices ...string) *DeleteByQueryService

Indices sets the indices on which to perform the delete operation.

func (*DeleteByQueryService) Pretty Uses

func (s *DeleteByQueryService) Pretty(pretty bool) *DeleteByQueryService

Pretty indents the JSON output from Elasticsearch.

func (*DeleteByQueryService) Q Uses

func (s *DeleteByQueryService) Q(query string) *DeleteByQueryService

Q specifies the query in Lucene query string syntax. You can also use Query to programmatically specify the query.

func (*DeleteByQueryService) Query Uses

func (s *DeleteByQueryService) Query(query Query) *DeleteByQueryService

Query sets the query programmatically.

func (*DeleteByQueryService) QueryString Uses

func (s *DeleteByQueryService) QueryString(query string) *DeleteByQueryService

QueryString is an alias to Q. Notice that you can also use Query to programmatically set the query.

func (*DeleteByQueryService) Replication Uses

func (s *DeleteByQueryService) Replication(replication string) *DeleteByQueryService

Replication sets a specific replication type (sync or async).

func (*DeleteByQueryService) Routing Uses

func (s *DeleteByQueryService) Routing(routing string) *DeleteByQueryService

Routing sets a specific routing value.

func (*DeleteByQueryService) Timeout Uses

func (s *DeleteByQueryService) Timeout(timeout string) *DeleteByQueryService

Timeout sets an explicit operation timeout, e.g. "1s" or "10000ms".

func (*DeleteByQueryService) Type Uses

func (s *DeleteByQueryService) Type(typ string) *DeleteByQueryService

Type limits the delete operation to the given type.

func (*DeleteByQueryService) Types Uses

func (s *DeleteByQueryService) Types(types ...string) *DeleteByQueryService

Types limits the delete operation to the given types.

type DeleteIndexResult Uses

type DeleteIndexResult struct {
    Acknowledged bool `json:"acknowledged"`
}

type DeleteIndexService Uses

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

Code:

// Get a client to the local Elasticsearch instance.
client, err := elastic.NewClient()
if err != nil {
    // Handle error
    panic(err)
}
// Delete an index.
deleteIndex, err := client.DeleteIndex("twitter").Do()
if err != nil {
    // Handle error
    panic(err)
}
if !deleteIndex.Acknowledged {
    // Not acknowledged
}

func NewDeleteIndexService Uses

func NewDeleteIndexService(client *Client) *DeleteIndexService

func (*DeleteIndexService) Do Uses

func (b *DeleteIndexService) Do() (*DeleteIndexResult, error)

func (*DeleteIndexService) Index Uses

func (b *DeleteIndexService) Index(index string) *DeleteIndexService

type DeleteMappingResponse Uses

type DeleteMappingResponse struct {
    Acknowledged bool `json:"acknowledged"`
}

DeleteMappingResponse is the response of DeleteMappingService.Do.

type DeleteMappingService Uses

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

DeleteMappingService allows to delete a mapping along with its data. See http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-delete-mapping.html.

func NewDeleteMappingService Uses

func NewDeleteMappingService(client *Client) *DeleteMappingService

NewDeleteMappingService creates a new DeleteMappingService.

func (*DeleteMappingService) Do Uses

func (s *DeleteMappingService) Do() (*DeleteMappingResponse, error)

Do executes the operation.

func (*DeleteMappingService) Index Uses

func (s *DeleteMappingService) Index(index ...string) *DeleteMappingService

Index is a list of index names (supports wildcards). Use `_all` for all indices.

func (*DeleteMappingService) MasterTimeout Uses

func (s *DeleteMappingService) MasterTimeout(masterTimeout string) *DeleteMappingService

MasterTimeout specifies the timeout for connecting to master.

func (*DeleteMappingService) Pretty Uses

func (s *DeleteMappingService) Pretty(pretty bool) *DeleteMappingService

Pretty indicates that the JSON response be indented and human readable.

func (*DeleteMappingService) Type Uses

func (s *DeleteMappingService) Type(typ ...string) *DeleteMappingService

Type is a list of document types to delete (supports wildcards). Use `_all` to delete all document types in the specified indices..

func (*DeleteMappingService) Validate Uses

func (s *DeleteMappingService) Validate() error

Validate checks if the operation is valid.

type DeleteResult Uses

type DeleteResult struct {
    Found   bool   `json:"found"`
    Index   string `json:"_index"`
    Type    string `json:"_type"`
    Id      string `json:"_id"`
    Version int64  `json:"_version"`
}

type DeleteService Uses

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

func NewDeleteService Uses

func NewDeleteService(client *Client) *DeleteService

func (*DeleteService) Do Uses

func (s *DeleteService) Do() (*DeleteResult, error)

Do deletes the document. It fails if any of index, type, and identifier are missing.

func (*DeleteService) Id Uses

func (s *DeleteService) Id(id string) *DeleteService

func (*DeleteService) Index Uses

func (s *DeleteService) Index(index string) *DeleteService

func (*DeleteService) Parent Uses

func (s *DeleteService) Parent(parent string) *DeleteService

func (*DeleteService) Pretty Uses

func (s *DeleteService) Pretty(pretty bool) *DeleteService

func (*DeleteService) Refresh Uses

func (s *DeleteService) Refresh(refresh bool) *DeleteService

func (*DeleteService) Type Uses

func (s *DeleteService) Type(_type string) *DeleteService

func (*DeleteService) Version Uses

func (s *DeleteService) Version(version int) *DeleteService

type DeleteTemplateResponse Uses

type DeleteTemplateResponse struct {
    Found   bool   `json:"found"`
    Index   string `json:"_index"`
    Type    string `json:"_type"`
    Id      string `json:"_id"`
    Version int    `json:"_version"`
}

DeleteTemplateResponse is the response of DeleteTemplateService.Do.

type DeleteTemplateService Uses

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

DeleteTemplateService deletes a search template. More information can be found at http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-template.html.

Code:

client, err := elastic.NewClient()
if err != nil {
    panic(err)
}

// Delete template
resp, err := client.DeleteTemplate().Id("my-search-template").Do()
if err != nil {
    panic(err)
}
if resp != nil && resp.Found {
    fmt.Println("template deleted")
}

func NewDeleteTemplateService Uses

func NewDeleteTemplateService(client *Client) *DeleteTemplateService

NewDeleteTemplateService creates a new DeleteTemplateService.

func (*DeleteTemplateService) Do Uses

func (s *DeleteTemplateService) Do() (*DeleteTemplateResponse, error)

Do executes the operation.

func (*DeleteTemplateService) Id Uses

func (s *DeleteTemplateService) Id(id string) *DeleteTemplateService

Id is the template ID.

func (*DeleteTemplateService) Validate Uses

func (s *DeleteTemplateService) Validate() error

Validate checks if the operation is valid.

func (*DeleteTemplateService) Version Uses

func (s *DeleteTemplateService) Version(version int) *DeleteTemplateService

Version an explicit version number for concurrency control.

func (*DeleteTemplateService) VersionType Uses

func (s *DeleteTemplateService) VersionType(versionType string) *DeleteTemplateService

VersionType specifies a version type.

type DeleteWarmerResponse Uses

type DeleteWarmerResponse struct {
    Acknowledged bool `json:"acknowledged"`
}

DeleteWarmerResponse is the response of IndicesDeleteWarmerService.Do.

type DirectCandidateGenerator Uses

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

DirectCandidateGenerator implements a direct candidate generator. See http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-suggesters-phrase.html#_smoothing_models for details about smoothing models.

func NewDirectCandidateGenerator Uses

func NewDirectCandidateGenerator(field string) *DirectCandidateGenerator

func (*DirectCandidateGenerator) Accuracy Uses

func (g *DirectCandidateGenerator) Accuracy(accuracy float64) *DirectCandidateGenerator

func (*DirectCandidateGenerator) Field Uses

func (g *DirectCandidateGenerator) Field(field string) *DirectCandidateGenerator

func (*DirectCandidateGenerator) MaxEdits Uses

func (g *DirectCandidateGenerator) MaxEdits(maxEdits int) *DirectCandidateGenerator

func (*DirectCandidateGenerator) MaxInspections Uses

func (g *DirectCandidateGenerator) MaxInspections(maxInspections int) *DirectCandidateGenerator

func (*DirectCandidateGenerator) MaxTermFreq Uses

func (g *DirectCandidateGenerator) MaxTermFreq(maxTermFreq float64) *DirectCandidateGenerator

func (*DirectCandidateGenerator) MinDocFreq Uses

func (g *DirectCandidateGenerator) MinDocFreq(minDocFreq float64) *DirectCandidateGenerator

func (*DirectCandidateGenerator) MinWordLength Uses

func (g *DirectCandidateGenerator) MinWordLength(minWordLength int) *DirectCandidateGenerator

func (*DirectCandidateGenerator) PostFilter Uses

func (g *DirectCandidateGenerator) PostFilter(postFilter string) *DirectCandidateGenerator

func (*DirectCandidateGenerator) PreFilter Uses

func (g *DirectCandidateGenerator) PreFilter(preFilter string) *DirectCandidateGenerator

func (*DirectCandidateGenerator) PrefixLength Uses

func (g *DirectCandidateGenerator) PrefixLength(prefixLength int) *DirectCandidateGenerator

func (*DirectCandidateGenerator) Size Uses

func (g *DirectCandidateGenerator) Size(size int) *DirectCandidateGenerator

func (*DirectCandidateGenerator) Sort Uses

func (g *DirectCandidateGenerator) Sort(sort string) *DirectCandidateGenerator

func (*DirectCandidateGenerator) Source Uses

func (g *DirectCandidateGenerator) Source() interface{}

func (*DirectCandidateGenerator) StringDistance Uses

func (g *DirectCandidateGenerator) StringDistance(stringDistance string) *DirectCandidateGenerator

func (*DirectCandidateGenerator) SuggestMode Uses

func (g *DirectCandidateGenerator) SuggestMode(suggestMode string) *DirectCandidateGenerator

func (*DirectCandidateGenerator) Type Uses

func (g *DirectCandidateGenerator) Type() string

type DisMaxQuery Uses

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

A query that generates the union of documents produced by its subqueries, and that scores each document with the maximum score for that document as produced by any subquery, plus a tie breaking increment for any additional matching subqueries.

For more details, see: http://www.elasticsearch.org/guide/reference/query-dsl/dis-max-query/

func NewDisMaxQuery Uses

func NewDisMaxQuery() DisMaxQuery

Creates a new dis_max query.

func (DisMaxQuery) Boost Uses

func (q DisMaxQuery) Boost(boost float32) DisMaxQuery

func (DisMaxQuery) Query Uses

func (q DisMaxQuery) Query(query Query) DisMaxQuery

func (DisMaxQuery) Source Uses

func (q DisMaxQuery) Source() interface{}

Creates the query source for the dis_max query.

func (DisMaxQuery) TieBreaker Uses

func (q DisMaxQuery) TieBreaker(tieBreaker float32) DisMaxQuery

type Error Uses

type Error struct {
    Status  int    `json:"status"`
    Message string `json:"error"`
}

Error encapsulates error details as returned from Elasticsearch.

func (*Error) Error Uses

func (e *Error) Error() string

Error returns a string representation of the error.

type ExistsFilter Uses

type ExistsFilter struct {
    Filter
    // contains filtered or unexported fields
}

Filters documents where a specific field has a value in them. For details, see: http://www.elasticsearch.org/guide/reference/query-dsl/exists-filter.html

func NewExistsFilter Uses

func NewExistsFilter(name string) ExistsFilter

func (ExistsFilter) FilterName Uses

func (f ExistsFilter) FilterName(filterName string) ExistsFilter

func (ExistsFilter) Source Uses

func (f ExistsFilter) Source() interface{}

type ExistsService Uses

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

ExistsService checks if a document exists.

See http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html for details.

func NewExistsService Uses

func NewExistsService(client *Client) *ExistsService

NewExistsService creates a new ExistsService.

func (*ExistsService) Do Uses

func (s *ExistsService) Do() (bool, error)

Do executes the operation.

func (*ExistsService) Id Uses

func (s *ExistsService) Id(id string) *ExistsService

Id is the document ID.

func (*ExistsService) Index Uses

func (s *ExistsService) Index(index string) *ExistsService

Index is the name of the index.

func (*ExistsService) Parent Uses

func (s *ExistsService) Parent(parent string) *ExistsService

Parent is the ID of the parent document.

func (*ExistsService) Preference Uses

func (s *ExistsService) Preference(preference string) *ExistsService

Preference specifies the node or shard the operation should be performed on (default: random).

func (*ExistsService) Pretty Uses

func (s *ExistsService) Pretty(pretty bool) *ExistsService

Pretty indicates that the JSON response be indented and human readable.

func (*ExistsService) Realtime Uses

func (s *ExistsService) Realtime(realtime bool) *ExistsService

Realtime specifies whether to perform the operation in realtime or search mode.

func (*ExistsService) Refresh Uses

func (s *ExistsService) Refresh(refresh bool) *ExistsService

Refresh the shard containing the document before performing the operation.

func (*ExistsService) Routing Uses

func (s *ExistsService) Routing(routing string) *ExistsService

Routing is the specific routing value.

func (*ExistsService) Type Uses

func (s *ExistsService) Type(typ string) *ExistsService

Type is the type of the document (use `_all` to fetch the first document matching the ID across all types).

func (*ExistsService) Validate Uses

func (s *ExistsService) Validate() error

Validate checks if the operation is valid.

type ExplainResponse Uses

type ExplainResponse struct {
    Index       string                 `json:"_index"`
    Type        string                 `json:"_type"`
    Id          string                 `json:"_id"`
    Matched     bool                   `json:"matched"`
    Explanation map[string]interface{} `json:"explanation"`
}

ExplainResponse is the response of ExplainService.Do.

type ExplainService Uses

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

ExplainService computes a score explanation for a query and a specific document. See http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-explain.html.

func NewExplainService Uses

func NewExplainService(client *Client) *ExplainService

NewExplainService creates a new ExplainService.

func (*ExplainService) AnalyzeWildcard Uses

func (s *ExplainService) AnalyzeWildcard(analyzeWildcard bool) *ExplainService

AnalyzeWildcard specifies whether wildcards and prefix queries in the query string query should be analyzed (default: false).

func (*ExplainService) Analyzer Uses

func (s *ExplainService) Analyzer(analyzer string) *ExplainService

Analyzer is the analyzer for the query string query.

func (*ExplainService) BodyJson Uses

func (s *ExplainService) BodyJson(body interface{}) *ExplainService

BodyJson sets the query definition using the Query DSL.

func (*ExplainService) BodyString Uses

func (s *ExplainService) BodyString(body string) *ExplainService

BodyString sets the query definition using the Query DSL as a string.

func (*ExplainService) DefaultOperator Uses

func (s *ExplainService) DefaultOperator(defaultOperator string) *ExplainService

DefaultOperator is the default operator for query string query (AND or OR).

func (*ExplainService) Df Uses

func (s *ExplainService) Df(df string) *ExplainService

Df is the default field for query string query (default: _all).

func (*ExplainService) Do Uses

func (s *ExplainService) Do() (*ExplainResponse, error)

Do executes the operation.

func (*ExplainService) Fields Uses

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

Fields is a list of fields to return in the response.

func (*ExplainService) Id Uses

func (s *ExplainService) Id(id string) *ExplainService

Id is the document ID.

func (*ExplainService) Index Uses

func (s *ExplainService) Index(index string) *ExplainService

Index is the name of the index.

func (*ExplainService) Lenient Uses

func (s *ExplainService) Lenient(lenient bool) *ExplainService

Lenient specifies whether format-based query failures (such as providing text to a numeric field) should be ignored.

func (*ExplainService) LowercaseExpandedTerms Uses

func (s *ExplainService) LowercaseExpandedTerms(lowercaseExpandedTerms bool) *ExplainService

LowercaseExpandedTerms specifies whether query terms should be lowercased.

func (*ExplainService) Parent Uses

func (s *ExplainService) Parent(parent string) *ExplainService

Parent is the ID of the parent document.

func (*ExplainService) Preference Uses

func (s *ExplainService) Preference(preference string) *ExplainService

Preference specifies the node or shard the operation should be performed on (default: random).

func (*ExplainService) Pretty Uses

func (s *ExplainService) Pretty(pretty bool) *ExplainService

Pretty indicates that the JSON response be indented and human readable.

func (*ExplainService) Q Uses

func (s *ExplainService) Q(q string) *ExplainService

Query in the Lucene query string syntax.

func (*ExplainService) Query Uses

func (s *ExplainService) Query(query Query) *ExplainService

Query sets a query definition using the Query DSL.

func (*ExplainService)