summaryrefslogtreecommitdiffstats
path: root/vendor/gopkg.in
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2017-06-21 19:06:17 -0700
committerCorey Hulen <corey@hulen.com>2017-06-21 19:06:17 -0700
commit42f28ab8e374137fe3f5d25424489d879d4724f8 (patch)
tree20353f2446b506d32e6d353b72a57bf48f070389 /vendor/gopkg.in
parent6b39c308d882a0aeac533f8ab1d90b48a2ae4b5a (diff)
downloadchat-42f28ab8e374137fe3f5d25424489d879d4724f8.tar.gz
chat-42f28ab8e374137fe3f5d25424489d879d4724f8.tar.bz2
chat-42f28ab8e374137fe3f5d25424489d879d4724f8.zip
Updating server dependancies (#6712)
Diffstat (limited to 'vendor/gopkg.in')
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/.travis.yml6
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/CODE_OF_CONDUCT.md46
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/CONTRIBUTORS5
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/README.md7
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/client.go24
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/client_test.go143
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/cluster_stats.go10
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/delete.go14
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/ingest_get_pipeline_test.go27
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/nodes_stats.go2
-rwxr-xr-xvendor/gopkg.in/olivere/elastic.v5/run-es-5.4.1.sh1
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_aggs.go42
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_percentiles_bucket.go125
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_percentiles_bucket_test.go44
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/search_aggs_test.go28
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/snapshot_create.go186
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/snapshot_create_test.go63
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/suggester_completion.go2
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/suggester_completion_test.go4
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/suggester_context_category.go36
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/suggester_context_category_test.go74
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/update.go14
22 files changed, 842 insertions, 61 deletions
diff --git a/vendor/gopkg.in/olivere/elastic.v5/.travis.yml b/vendor/gopkg.in/olivere/elastic.v5/.travis.yml
index c2aa4b378..c31c1805d 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/.travis.yml
+++ b/vendor/gopkg.in/olivere/elastic.v5/.travis.yml
@@ -10,8 +10,6 @@ matrix:
services:
- docker
before_script:
- - mkdir -p /tmp/elasticsearch/config
- - cp -r config/* /tmp/elasticsearch/config/
- sudo sysctl -w vm.max_map_count=262144
- - docker run --rm --privileged=true -p 9200:9200 -p 9300:9300 -v "/tmp/elasticsearch/config:/usr/share/elasticsearch/config" -e ES_JAVA_OPTS='-Xms1g -Xmx1g' elasticsearch:5.4.0 elasticsearch >& /dev/null &
- - sleep 15
+ - docker run --rm --privileged=true -p 9200:9200 -p 9300:9300 -e "bootstrap.memory_lock=true" -e "ES_JAVA_OPTS=-Xms1g -Xmx1g" docker.elastic.co/elasticsearch/elasticsearch:5.4.1 elasticsearch -Expack.security.enabled=false -Escript.inline=true -Escript.stored=true -Escript.file=true -Enetwork.host=_local_,_site_ -Enetwork.publish_host=_local_ >& /dev/null &
+ - sleep 30
diff --git a/vendor/gopkg.in/olivere/elastic.v5/CODE_OF_CONDUCT.md b/vendor/gopkg.in/olivere/elastic.v5/CODE_OF_CONDUCT.md
new file mode 100644
index 000000000..acefecee5
--- /dev/null
+++ b/vendor/gopkg.in/olivere/elastic.v5/CODE_OF_CONDUCT.md
@@ -0,0 +1,46 @@
+# Contributor Covenant Code of Conduct
+
+## Our Pledge
+
+In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
+
+## Our Standards
+
+Examples of behavior that contributes to creating a positive environment include:
+
+* Using welcoming and inclusive language
+* Being respectful of differing viewpoints and experiences
+* Gracefully accepting constructive criticism
+* Focusing on what is best for the community
+* Showing empathy towards other community members
+
+Examples of unacceptable behavior by participants include:
+
+* The use of sexualized language or imagery and unwelcome sexual attention or advances
+* Trolling, insulting/derogatory comments, and personal or political attacks
+* Public or private harassment
+* Publishing others' private information, such as a physical or electronic address, without explicit permission
+* Other conduct which could reasonably be considered inappropriate in a professional setting
+
+## Our Responsibilities
+
+Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
+
+Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
+
+## Scope
+
+This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
+
+## Enforcement
+
+Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at oliver@eilhard.net. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
+
+Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
+
+## Attribution
+
+This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
+
+[homepage]: http://contributor-covenant.org
+[version]: http://contributor-covenant.org/version/1/4/
diff --git a/vendor/gopkg.in/olivere/elastic.v5/CONTRIBUTORS b/vendor/gopkg.in/olivere/elastic.v5/CONTRIBUTORS
index 7e63e9eac..6bce05cf7 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/CONTRIBUTORS
+++ b/vendor/gopkg.in/olivere/elastic.v5/CONTRIBUTORS
@@ -36,7 +36,9 @@ Dwayne Schultz [@myshkin5](https://github.com/myshkin5)
Ellison Leão [@ellisonleao](https://github.com/ellisonleao)
Erwin [@eticzon](https://github.com/eticzon)
Eugene Egorov [@EugeneEgorov](https://github.com/EugeneEgorov)
+Fanfan [@wenpos](https://github.com/wenpos)
Faolan C-P [@fcheslack](https://github.com/fcheslack)
+Filip Tepper [@filiptepper](https://github.com/filiptepper)
Gerhard Häring [@ghaering](https://github.com/ghaering)
Guilherme Silveira [@guilherme-santos](https://github.com/guilherme-santos)
Guillaume J. Charmes [@creack](https://github.com/creack)
@@ -58,6 +60,7 @@ John Stanford [@jxstanford](https://github.com/jxstanford)
jun [@coseyo](https://github.com/coseyo)
Junpei Tsuji [@jun06t](https://github.com/jun06t)
Kenta SUZUKI [@suzuken](https://github.com/suzuken)
+Kevin Mulvey [@kmulvey](https://github.com/kmulvey)
Kyle Brandt [@kylebrandt](https://github.com/kylebrandt)
Leandro Piccilli [@lpic10](https://github.com/lpic10)
Maciej Lisiewski [@c2h5oh](https://github.com/c2h5oh)
@@ -75,6 +78,7 @@ Nicholas Wolff [@nwolff](https://github.com/nwolff)
Nick K [@utrack](https://github.com/utrack)
Nick Whyte [@nickw444](https://github.com/nickw444)
Orne Brocaar [@brocaar](https://github.com/brocaar)
+Pete C [@peteclark-ft](https://github.com/peteclark-ft)
Radoslaw Wesolowski [r--w](https://github.com/r--w)
Ryan Schmukler [@rschmukler](https://github.com/rschmukler)
Sacheendra talluri [@sacheendra](https://github.com/sacheendra)
@@ -89,6 +93,7 @@ Tetsuya Morimoto [@t2y](https://github.com/t2y)
TimeEmit [@TimeEmit](https://github.com/timeemit)
TusharM [@tusharm](https://github.com/tusharm)
wangtuo [@wangtuo](https://github.com/wangtuo)
+Wédney Yuri [@wedneyyuri](https://github.com/wedneyyuri)
wolfkdy [@wolfkdy](https://github.com/wolfkdy)
Wyndham Blanton [@wyndhblb](https://github.com/wyndhblb)
Yarden Bar [@ayashjorden](https://github.com/ayashjorden)
diff --git a/vendor/gopkg.in/olivere/elastic.v5/README.md b/vendor/gopkg.in/olivere/elastic.v5/README.md
index c57d2fea3..ececd2769 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/README.md
+++ b/vendor/gopkg.in/olivere/elastic.v5/README.md
@@ -284,7 +284,7 @@ See the [wiki](https://github.com/olivere/elastic/wiki) for more details.
- [x] Sum Bucket
- [x] Stats Bucket
- [ ] Extended Stats Bucket
- - [ ] Percentiles Bucket
+ - [x] Percentiles Bucket
- [x] Moving Average
- [x] Cumulative Sum
- [x] Bucket Script
@@ -458,8 +458,9 @@ and
Elastic uses portions of the
[uritemplates](https://github.com/jtacoma/uritemplates) library
-by Joshua Tacoma and
-[backoff](https://github.com/cenkalti/backoff) by Cenk Altı.
+by Joshua Tacoma,
+[backoff](https://github.com/cenkalti/backoff) by Cenk Altı and
+[leaktest](https://github.com/fortytw2/leaktest) by Ian Chiles.
## LICENSE
diff --git a/vendor/gopkg.in/olivere/elastic.v5/client.go b/vendor/gopkg.in/olivere/elastic.v5/client.go
index df0d9a7dd..c8cb17c87 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/client.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/client.go
@@ -22,7 +22,7 @@ import (
const (
// Version is the current version of Elastic.
- Version = "5.0.38"
+ Version = "5.0.41"
// 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.
@@ -817,8 +817,12 @@ func (c *Client) sniff(timeout time.Duration) error {
// Start sniffing on all found URLs
ch := make(chan []*conn, len(urls))
+
+ ctx, cancel := context.WithTimeout(context.Background(), timeout)
+ defer cancel()
+
for _, url := range urls {
- go func(url string) { ch <- c.sniffNode(url) }(url)
+ go func(url string) { ch <- c.sniffNode(ctx, url) }(url)
}
// Wait for the results to come back, or the process times out.
@@ -829,7 +833,7 @@ func (c *Client) sniff(timeout time.Duration) error {
c.updateConns(conns)
return nil
}
- case <-time.After(timeout):
+ case <-ctx.Done():
// We get here if no cluster responds in time
return errors.Wrap(ErrNoClient, "sniff timeout")
}
@@ -840,7 +844,7 @@ func (c *Client) sniff(timeout time.Duration) error {
// in sniff. If successful, it returns the list of node URLs extracted
// from the result of calling Nodes Info API. Otherwise, an empty array
// is returned.
-func (c *Client) sniffNode(url string) []*conn {
+func (c *Client) sniffNode(ctx context.Context, url string) []*conn {
var nodes []*conn
// Call the Nodes Info API at /_nodes/http
@@ -855,7 +859,7 @@ func (c *Client) sniffNode(url string) []*conn {
}
c.mu.RUnlock()
- res, err := c.c.Do((*http.Request)(req))
+ res, err := c.c.Do((*http.Request)(req).WithContext(ctx))
if err != nil {
return nodes
}
@@ -995,7 +999,7 @@ func (c *Client) healthcheck(timeout time.Duration, force bool) {
if basicAuth {
req.SetBasicAuth(basicAuthUsername, basicAuthPassword)
}
- res, err := c.c.Do((*http.Request)(req))
+ res, err := c.c.Do((*http.Request)(req).WithContext(ctx))
if res != nil {
status = res.StatusCode
if res.Body != nil {
@@ -1103,7 +1107,7 @@ func (c *Client) next() (*conn, error) {
}
// We tried hard, but there is no node available
- return nil, errors.Wrap(ErrNoClient, "no avaiable connection")
+ return nil, errors.Wrap(ErrNoClient, "no available connection")
}
// mustActiveConn returns nil if there is an active connection,
@@ -1629,12 +1633,16 @@ func (c *Client) TasksList() *TasksListService {
// -- Snapshot and Restore --
-// TODO Snapshot Create
// TODO Snapshot Delete
// TODO Snapshot Get
// TODO Snapshot Restore
// TODO Snapshot Status
+// SnapshotCreate creates a snapshot.
+func (c *Client) SnapshotCreate(repository string, snapshot string) *SnapshotCreateService {
+ return NewSnapshotCreateService(c).Repository(repository).Snapshot(snapshot)
+}
+
// SnapshotCreateRepository creates or updates a snapshot repository.
func (c *Client) SnapshotCreateRepository(repository string) *SnapshotCreateRepositoryService {
return NewSnapshotCreateRepositoryService(c).Repository(repository)
diff --git a/vendor/gopkg.in/olivere/elastic.v5/client_test.go b/vendor/gopkg.in/olivere/elastic.v5/client_test.go
index 46aa42619..a6fe011e9 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/client_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/client_test.go
@@ -11,11 +11,15 @@ import (
"errors"
"fmt"
"log"
+ "net"
"net/http"
+ "reflect"
"regexp"
"strings"
"testing"
"time"
+
+ "github.com/fortytw2/leaktest"
)
func findConn(s string, slice ...*conn) (int, bool) {
@@ -279,6 +283,74 @@ func TestClientHealthcheckStartupTimeout(t *testing.T) {
}
}
+func TestClientHealthcheckTimeoutLeak(t *testing.T) {
+ // This test test checks if healthcheck requests are canceled
+ // after timeout.
+ // It contains couple of hacks which won't be needed once we
+ // stop supporting Go1.7.
+ // On Go1.7 it uses server side effects to monitor if connection
+ // was closed,
+ // and on Go 1.8+ we're additionally honestly monitoring routine
+ // leaks via leaktest.
+ mux := http.NewServeMux()
+
+ var reqDone bool
+ mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
+ cn, ok := w.(http.CloseNotifier)
+ if !ok {
+ t.Fatalf("Writer is not CloseNotifier, but %v", reflect.TypeOf(w).Name())
+ }
+ <-cn.CloseNotify()
+ reqDone = true
+ })
+
+ lis, err := net.Listen("tcp", "127.0.0.1:0")
+ if err != nil {
+ t.Fatalf("Couldn't setup listener: %v", err)
+ }
+ addr := lis.Addr().String()
+
+ srv := &http.Server{
+ Handler: mux,
+ }
+ go srv.Serve(lis)
+
+ cli := &Client{
+ c: &http.Client{},
+ conns: []*conn{
+ &conn{
+ url: "http://" + addr + "/",
+ },
+ },
+ }
+
+ type closer interface {
+ Shutdown(context.Context) error
+ }
+
+ // pre-Go1.8 Server can't Shutdown
+ cl, isServerCloseable := (interface{}(srv)).(closer)
+
+ // Since Go1.7 can't Shutdown() - there will be leak from server
+ // Monitor leaks on Go 1.8+
+ if isServerCloseable {
+ defer leaktest.CheckTimeout(t, time.Second*10)()
+ }
+
+ cli.healthcheck(time.Millisecond*500, true)
+
+ if isServerCloseable {
+ ctx, cancel := context.WithTimeout(context.Background(), time.Second)
+ defer cancel()
+ cl.Shutdown(ctx)
+ }
+
+ <-time.After(time.Second)
+ if !reqDone {
+ t.Fatal("Request wasn't canceled or stopped")
+ }
+}
+
// -- NewSimpleClient --
func TestSimpleClientDefaults(t *testing.T) {
@@ -415,7 +487,7 @@ func TestClientSniffNode(t *testing.T) {
}
ch := make(chan []*conn)
- go func() { ch <- client.sniffNode(DefaultURL) }()
+ go func() { ch <- client.sniffNode(context.Background(), DefaultURL) }()
select {
case nodes := <-ch:
@@ -469,6 +541,75 @@ func TestClientSniffOnDefaultURL(t *testing.T) {
}
}
+func TestClientSniffTimeoutLeak(t *testing.T) {
+ // This test test checks if sniff requests are canceled
+ // after timeout.
+ // It contains couple of hacks which won't be needed once we
+ // stop supporting Go1.7.
+ // On Go1.7 it uses server side effects to monitor if connection
+ // was closed,
+ // and on Go 1.8+ we're additionally honestly monitoring routine
+ // leaks via leaktest.
+ mux := http.NewServeMux()
+
+ var reqDone bool
+ mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
+ cn, ok := w.(http.CloseNotifier)
+ if !ok {
+ t.Fatalf("Writer is not CloseNotifier, but %v", reflect.TypeOf(w).Name())
+ }
+ <-cn.CloseNotify()
+ reqDone = true
+ })
+
+ lis, err := net.Listen("tcp", "127.0.0.1:0")
+ if err != nil {
+ t.Fatalf("Couldn't setup listener: %v", err)
+ }
+ addr := lis.Addr().String()
+
+ srv := &http.Server{
+ Handler: mux,
+ }
+ go srv.Serve(lis)
+
+ cli := &Client{
+ c: &http.Client{},
+ conns: []*conn{
+ &conn{
+ url: "http://" + addr + "/",
+ },
+ },
+ snifferEnabled: true,
+ }
+
+ type closer interface {
+ Shutdown(context.Context) error
+ }
+
+ // pre-Go1.8 Server can't Shutdown
+ cl, isServerCloseable := (interface{}(srv)).(closer)
+
+ // Since Go1.7 can't Shutdown() - there will be leak from server
+ // Monitor leaks on Go 1.8+
+ if isServerCloseable {
+ defer leaktest.CheckTimeout(t, time.Second*10)()
+ }
+
+ cli.sniff(time.Millisecond * 500)
+
+ if isServerCloseable {
+ ctx, cancel := context.WithTimeout(context.Background(), time.Second)
+ defer cancel()
+ cl.Shutdown(ctx)
+ }
+
+ <-time.After(time.Second)
+ if !reqDone {
+ t.Fatal("Request wasn't canceled or stopped")
+ }
+}
+
func TestClientExtractHostname(t *testing.T) {
tests := []struct {
Scheme string
diff --git a/vendor/gopkg.in/olivere/elastic.v5/cluster_stats.go b/vendor/gopkg.in/olivere/elastic.v5/cluster_stats.go
index aa9b4783d..8c5374d0f 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/cluster_stats.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/cluster_stats.go
@@ -249,11 +249,11 @@ type ClusterStatsNodes struct {
}
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"`
+ Total int `json:"total"`
+ Data int `json:"data"`
+ CoordinatingOnly int `json:"coordinating_only"`
+ Master int `json:"master"`
+ Ingest int `json:"ingest"`
}
type ClusterStatsNodesOsStats struct {
diff --git a/vendor/gopkg.in/olivere/elastic.v5/delete.go b/vendor/gopkg.in/olivere/elastic.v5/delete.go
index a0ab550c1..991338715 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/delete.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/delete.go
@@ -199,10 +199,12 @@ func (s *DeleteService) Do(ctx context.Context) (*DeleteResponse, error) {
// DeleteResponse is the outcome of running DeleteService.Do.
type DeleteResponse struct {
- // TODO _shards { total, failed, successful }
- Found bool `json:"found"`
- Index string `json:"_index"`
- Type string `json:"_type"`
- Id string `json:"_id"`
- Version int64 `json:"_version"`
+ Index string `json:"_index"`
+ Type string `json:"_type"`
+ Id string `json:"_id"`
+ Version int64 `json:"_version"`
+ Shards *shardsInfo `json:"_shards"`
+ Result bool `json:"string,omitempty"`
+ ForcedRefresh bool `json:"forced_refresh,omitempty"`
+ Found bool `json:"found"`
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/ingest_get_pipeline_test.go b/vendor/gopkg.in/olivere/elastic.v5/ingest_get_pipeline_test.go
index ddafe9fce..009b717ca 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/ingest_get_pipeline_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/ingest_get_pipeline_test.go
@@ -48,14 +48,17 @@ func TestIngestGetPipelineURL(t *testing.T) {
func TestIngestLifecycle(t *testing.T) {
client := setupTestClientAndCreateIndexAndAddDocs(t) //, SetTraceLog(log.New(os.Stdout, "", 0)))
- // Get all pipelines (returns 404 that indicates an error)
- getres, err := client.IngestGetPipeline().Do(context.TODO())
- if err == nil {
- t.Fatal(err)
- }
- if getres != nil {
- t.Fatalf("expected no response, got %v", getres)
- }
+ // With the new ES Docker images, XPack is already installed and returns a pipeline. So we cannot test for "no pipelines". Skipping for now.
+ /*
+ // Get all pipelines (returns 404 that indicates an error)
+ getres, err := client.IngestGetPipeline().Do(context.TODO())
+ if err == nil {
+ t.Fatal(err)
+ }
+ if getres != nil {
+ t.Fatalf("expected no response, got %v", getres)
+ }
+ //*/
// Add a pipeline
pipelineDef := `{
@@ -81,18 +84,18 @@ func TestIngestLifecycle(t *testing.T) {
}
// Get all pipelines again
- getres, err = client.IngestGetPipeline().Do(context.TODO())
+ getres, err := client.IngestGetPipeline().Do(context.TODO())
if err != nil {
t.Fatal(err)
}
- if want, have := 1, len(getres); want != have {
- t.Fatalf("expected %d pipelines, got %d", want, have)
+ if have := len(getres); have == 0 {
+ t.Fatalf("expected at least 1 pipeline, got %d", have)
}
if _, found := getres["my-pipeline"]; !found {
t.Fatalf("expected to find pipline with id %q", "my-pipeline")
}
- // Get all pipeline by ID
+ // Get pipeline by ID
getres, err = client.IngestGetPipeline("my-pipeline").Do(context.TODO())
if err != nil {
t.Fatal(err)
diff --git a/vendor/gopkg.in/olivere/elastic.v5/nodes_stats.go b/vendor/gopkg.in/olivere/elastic.v5/nodes_stats.go
index 29484a041..a955bb426 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/nodes_stats.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/nodes_stats.go
@@ -274,7 +274,7 @@ type NodesStatsNode struct {
HTTP *NodesStatsNodeHTTP `json:"http"`
// Breaker contains information about circuit breakers.
- Breaker map[string]*NodesStatsBreaker `json:"breaker"`
+ Breaker map[string]*NodesStatsBreaker `json:"breakers"`
// ScriptStats information.
ScriptStats *NodesStatsScriptStats `json:"script"`
diff --git a/vendor/gopkg.in/olivere/elastic.v5/run-es-5.4.1.sh b/vendor/gopkg.in/olivere/elastic.v5/run-es-5.4.1.sh
new file mode 100755
index 000000000..cb5f44189
--- /dev/null
+++ b/vendor/gopkg.in/olivere/elastic.v5/run-es-5.4.1.sh
@@ -0,0 +1 @@
+docker run --rm --privileged=true -p 9200:9200 -p 9300:9300 -v "$PWD/config:/usr/share/elasticsearch/config" -e ES_JAVA_OPTS='-Xms1g -Xmx1g' elasticsearch:5.4.1 elasticsearch
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_aggs.go b/vendor/gopkg.in/olivere/elastic.v5/search_aggs.go
index cb106dbf5..a43f8ddcc 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_aggs.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_aggs.go
@@ -533,6 +533,21 @@ func (a Aggregations) StatsBucket(name string) (*AggregationPipelineStatsMetric,
return nil, false
}
+// PercentilesBucket returns stats bucket pipeline aggregation results.
+// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-pipeline-percentiles-bucket-aggregation.html
+func (a Aggregations) PercentilesBucket(name string) (*AggregationPipelinePercentilesMetric, bool) {
+ if raw, found := a[name]; found {
+ agg := new(AggregationPipelinePercentilesMetric)
+ if raw == nil {
+ return agg, true
+ }
+ if err := json.Unmarshal(*raw, agg); err == nil {
+ return agg, true
+ }
+ }
+ return nil, false
+}
+
// MaxBucket returns maximum bucket pipeline aggregation results.
// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-pipeline-max-bucket-aggregation.html
func (a Aggregations) MaxBucket(name string) (*AggregationPipelineBucketMetricValue, bool) {
@@ -1406,3 +1421,30 @@ func (a *AggregationPipelineStatsMetric) UnmarshalJSON(data []byte) error {
a.Aggregations = aggs
return nil
}
+
+// -- Pipeline percentiles
+
+// AggregationPipelinePercentilesMetric is the value returned by a pipeline
+// percentiles Metric aggregation
+type AggregationPipelinePercentilesMetric struct {
+ Aggregations
+
+ Values map[string]float64 // `json:"values"`
+ Meta map[string]interface{} // `json:"meta,omitempty"`
+}
+
+// UnmarshalJSON decodes JSON data and initializes an AggregationPipelinePercentilesMetric structure.
+func (a *AggregationPipelinePercentilesMetric) UnmarshalJSON(data []byte) error {
+ var aggs map[string]*json.RawMessage
+ if err := json.Unmarshal(data, &aggs); err != nil {
+ return err
+ }
+ if v, ok := aggs["values"]; ok && v != nil {
+ json.Unmarshal(*v, &a.Values)
+ }
+ if v, ok := aggs["meta"]; ok && v != nil {
+ json.Unmarshal(*v, &a.Meta)
+ }
+ a.Aggregations = aggs
+ return nil
+}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_percentiles_bucket.go b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_percentiles_bucket.go
new file mode 100644
index 000000000..4caca7432
--- /dev/null
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_percentiles_bucket.go
@@ -0,0 +1,125 @@
+// Copyright 2012-2015 Oliver Eilhard. All rights reserved.
+// Use of this source code is governed by a MIT-license.
+// See http://olivere.mit-license.org/license.txt for details.
+
+package elastic
+
+// PercentilesBucketAggregation is a sibling pipeline aggregation which calculates
+// percentiles across all bucket of a specified metric in a sibling aggregation.
+// The specified metric must be numeric and the sibling aggregation must
+// be a multi-bucket aggregation.
+//
+// For more details, see
+// https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-percentiles-bucket-aggregation.html
+type PercentilesBucketAggregation struct {
+ format string
+ gapPolicy string
+ percents []float64
+ bucketsPaths []string
+
+ subAggregations map[string]Aggregation
+ meta map[string]interface{}
+}
+
+// NewPercentilesBucketAggregation creates and initializes a new PercentilesBucketAggregation.
+func NewPercentilesBucketAggregation() *PercentilesBucketAggregation {
+ return &PercentilesBucketAggregation{
+ subAggregations: make(map[string]Aggregation),
+ }
+}
+
+// Format to apply the output value of this aggregation.
+func (p *PercentilesBucketAggregation) Format(format string) *PercentilesBucketAggregation {
+ p.format = format
+ return p
+}
+
+// Percents to calculate percentiles for in this aggregation.
+func (p *PercentilesBucketAggregation) Percents(percents ...float64) *PercentilesBucketAggregation {
+ p.percents = percents
+ return p
+}
+
+// GapPolicy defines what should be done when a gap in the series is discovered.
+// Valid values include "insert_zeros" or "skip". Default is "insert_zeros".
+func (p *PercentilesBucketAggregation) GapPolicy(gapPolicy string) *PercentilesBucketAggregation {
+ p.gapPolicy = gapPolicy
+ return p
+}
+
+// GapInsertZeros inserts zeros for gaps in the series.
+func (p *PercentilesBucketAggregation) GapInsertZeros() *PercentilesBucketAggregation {
+ p.gapPolicy = "insert_zeros"
+ return p
+}
+
+// GapSkip skips gaps in the series.
+func (p *PercentilesBucketAggregation) GapSkip() *PercentilesBucketAggregation {
+ p.gapPolicy = "skip"
+ return p
+}
+
+// SubAggregation adds a sub-aggregation to this aggregation.
+func (p *PercentilesBucketAggregation) SubAggregation(name string, subAggregation Aggregation) *PercentilesBucketAggregation {
+ p.subAggregations[name] = subAggregation
+ return p
+}
+
+// Meta sets the meta data to be included in the aggregation response.
+func (p *PercentilesBucketAggregation) Meta(metaData map[string]interface{}) *PercentilesBucketAggregation {
+ p.meta = metaData
+ return p
+}
+
+// BucketsPath sets the paths to the buckets to use for this pipeline aggregator.
+func (p *PercentilesBucketAggregation) BucketsPath(bucketsPaths ...string) *PercentilesBucketAggregation {
+ p.bucketsPaths = append(p.bucketsPaths, bucketsPaths...)
+ return p
+}
+
+func (p *PercentilesBucketAggregation) Source() (interface{}, error) {
+ source := make(map[string]interface{})
+ params := make(map[string]interface{})
+ source["percentiles_bucket"] = params
+
+ if p.format != "" {
+ params["format"] = p.format
+ }
+ if p.gapPolicy != "" {
+ params["gap_policy"] = p.gapPolicy
+ }
+
+ // Add buckets paths
+ switch len(p.bucketsPaths) {
+ case 0:
+ case 1:
+ params["buckets_path"] = p.bucketsPaths[0]
+ default:
+ params["buckets_path"] = p.bucketsPaths
+ }
+
+ // Add percents
+ if len(p.percents) > 0 {
+ params["percents"] = p.percents
+ }
+
+ // AggregationBuilder (SubAggregations)
+ if len(p.subAggregations) > 0 {
+ aggsMap := make(map[string]interface{})
+ source["aggregations"] = aggsMap
+ for name, aggregate := range p.subAggregations {
+ src, err := aggregate.Source()
+ if err != nil {
+ return nil, err
+ }
+ aggsMap[name] = src
+ }
+ }
+
+ // Add Meta data if available
+ if len(p.meta) > 0 {
+ source["meta"] = p.meta
+ }
+
+ return source, nil
+}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_percentiles_bucket_test.go b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_percentiles_bucket_test.go
new file mode 100644
index 000000000..5fa2639de
--- /dev/null
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_pipeline_percentiles_bucket_test.go
@@ -0,0 +1,44 @@
+// Copyright 2012-present Oliver Eilhard. All rights reserved.
+// Use of this source code is governed by a MIT-license.
+// See http://olivere.mit-license.org/license.txt for details.
+
+package elastic
+
+import (
+ "encoding/json"
+ "testing"
+)
+
+func TestPercentilesBucketAggregation(t *testing.T) {
+ agg := NewPercentilesBucketAggregation().BucketsPath("the_sum").GapPolicy("skip")
+ src, err := agg.Source()
+ if err != nil {
+ t.Fatal(err)
+ }
+ data, err := json.Marshal(src)
+ if err != nil {
+ t.Fatalf("marshaling to JSON failed: %v", err)
+ }
+ got := string(data)
+ expected := `{"percentiles_bucket":{"buckets_path":"the_sum","gap_policy":"skip"}}`
+ if got != expected {
+ t.Errorf("expected\n%s\n,got:\n%s", expected, got)
+ }
+}
+
+func TestPercentilesBucketAggregationWithPercents(t *testing.T) {
+ agg := NewPercentilesBucketAggregation().BucketsPath("the_sum").Percents(0.1, 1.0, 5.0, 25, 50)
+ src, err := agg.Source()
+ if err != nil {
+ t.Fatal(err)
+ }
+ data, err := json.Marshal(src)
+ if err != nil {
+ t.Fatalf("marshaling to JSON failed: %v", err)
+ }
+ got := string(data)
+ expected := `{"percentiles_bucket":{"buckets_path":"the_sum","percents":[0.1,1,5,25,50]}}`
+ if got != expected {
+ t.Errorf("expected\n%s\n,got:\n%s", expected, got)
+ }
+}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_test.go b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_test.go
index 9bdcc75a2..c730e3b43 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/search_aggs_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/search_aggs_test.go
@@ -3067,6 +3067,34 @@ func TestAggsPipelineDerivative(t *testing.T) {
}
}
+func TestAggsPipelinePercentilesBucket(t *testing.T) {
+ s := `{
+ "sales_percentiles": {
+ "values": {
+ "25.0": 100,
+ "50.0": 200,
+ "75.0": 300
+ }
+ }
+}`
+ aggs := new(Aggregations)
+ err := json.Unmarshal([]byte(s), &aggs)
+ if err != nil {
+ t.Fatalf("expected no error decoding; got: %v", err)
+ }
+
+ agg, found := aggs.PercentilesBucket("sales_percentiles")
+ if !found {
+ t.Fatalf("expected aggregation to be found; got: %v", found)
+ }
+ if agg == nil {
+ t.Fatalf("expected aggregation != nil; got: %v", agg)
+ }
+ if len(agg.Values) != 3 {
+ t.Fatalf("expected aggregation map with three entries; got: %v", agg.Values)
+ }
+}
+
func TestAggsPipelineStatsBucket(t *testing.T) {
s := `{
"stats_monthly_sales": {
diff --git a/vendor/gopkg.in/olivere/elastic.v5/snapshot_create.go b/vendor/gopkg.in/olivere/elastic.v5/snapshot_create.go
new file mode 100644
index 000000000..245fdbff8
--- /dev/null
+++ b/vendor/gopkg.in/olivere/elastic.v5/snapshot_create.go
@@ -0,0 +1,186 @@
+// Copyright 2012-present Oliver Eilhard. All rights reserved.
+// Use of this source code is governed by a MIT-license.
+// See http://olivere.mit-license.org/license.txt for details.
+
+package elastic
+
+import (
+ "context"
+ "encoding/json"
+ "fmt"
+ "net/url"
+ "time"
+
+ "gopkg.in/olivere/elastic.v5/uritemplates"
+)
+
+// SnapshotCreateService is documented at https://www.elastic.co/guide/en/elasticsearch/reference/5.x/modules-snapshots.html.
+type SnapshotCreateService struct {
+ client *Client
+ pretty bool
+ repository string
+ snapshot string
+ masterTimeout string
+ waitForCompletion *bool
+ bodyJson interface{}
+ bodyString string
+}
+
+// NewSnapshotCreateService creates a new SnapshotCreateService.
+func NewSnapshotCreateService(client *Client) *SnapshotCreateService {
+ return &SnapshotCreateService{
+ client: client,
+ }
+}
+
+// Repository is the repository name.
+func (s *SnapshotCreateService) Repository(repository string) *SnapshotCreateService {
+ s.repository = repository
+ return s
+}
+
+// Snapshot is the snapshot name.
+func (s *SnapshotCreateService) Snapshot(snapshot string) *SnapshotCreateService {
+ s.snapshot = snapshot
+ return s
+}
+
+// MasterTimeout is documented as: Explicit operation timeout for connection to master node.
+func (s *SnapshotCreateService) MasterTimeout(masterTimeout string) *SnapshotCreateService {
+ s.masterTimeout = masterTimeout
+ return s
+}
+
+// WaitForCompletion is documented as: Should this request wait until the operation has completed before returning.
+func (s *SnapshotCreateService) WaitForCompletion(waitForCompletion bool) *SnapshotCreateService {
+ s.waitForCompletion = &waitForCompletion
+ return s
+}
+
+// Pretty indicates that the JSON response be indented and human readable.
+func (s *SnapshotCreateService) Pretty(pretty bool) *SnapshotCreateService {
+ s.pretty = pretty
+ return s
+}
+
+// BodyJson is documented as: The snapshot definition.
+func (s *SnapshotCreateService) BodyJson(body interface{}) *SnapshotCreateService {
+ s.bodyJson = body
+ return s
+}
+
+// BodyString is documented as: The snapshot definition.
+func (s *SnapshotCreateService) BodyString(body string) *SnapshotCreateService {
+ s.bodyString = body
+ return s
+}
+
+// buildURL builds the URL for the operation.
+func (s *SnapshotCreateService) buildURL() (string, url.Values, error) {
+ // Build URL
+ path, err := uritemplates.Expand("/_snapshot/{repository}/{snapshot}", map[string]string{
+ "snapshot": s.snapshot,
+ "repository": s.repository,
+ })
+ if err != nil {
+ return "", url.Values{}, err
+ }
+
+ // Add query string parameters
+ params := url.Values{}
+ if s.pretty {
+ params.Set("pretty", "1")
+ }
+ if s.masterTimeout != "" {
+ params.Set("master_timeout", s.masterTimeout)
+ }
+ if s.waitForCompletion != nil {
+ params.Set("wait_for_completion", fmt.Sprintf("%v", *s.waitForCompletion))
+ }
+ return path, params, nil
+}
+
+// Validate checks if the operation is valid.
+func (s *SnapshotCreateService) Validate() error {
+ var invalid []string
+ if s.repository == "" {
+ invalid = append(invalid, "Repository")
+ }
+ if s.snapshot == "" {
+ invalid = append(invalid, "Snapshot")
+ }
+ if len(invalid) > 0 {
+ return fmt.Errorf("missing required fields: %v", invalid)
+ }
+ return nil
+}
+
+// Do executes the operation.
+func (s *SnapshotCreateService) Do(ctx context.Context) (*SnapshotCreateResponse, error) {
+ // Check pre-conditions
+ if err := s.Validate(); err != nil {
+ return nil, err
+ }
+
+ // Get URL for request
+ path, params, err := s.buildURL()
+ if err != nil {
+ return nil, err
+ }
+
+ // Setup HTTP request body
+ var body interface{}
+ if s.bodyJson != nil {
+ body = s.bodyJson
+ } else {
+ body = s.bodyString
+ }
+
+ // Get HTTP response
+ res, err := s.client.PerformRequest(ctx, "PUT", path, params, body)
+ if err != nil {
+ return nil, err
+ }
+
+ // Return operation response
+ ret := new(SnapshotCreateResponse)
+ if err := json.Unmarshal(res.Body, ret); err != nil {
+ return nil, err
+ }
+ return ret, nil
+}
+
+// SnapshotShardFailure stores information about failures that occurred during shard snapshotting process.
+type SnapshotShardFailure struct {
+ Index string `json:"index"`
+ IndexUUID string `json:"index_uuid"`
+ ShardID int `json:"shard_id"`
+ Reason string `json:"reason"`
+ NodeID string `json:"node_id"`
+ Status string `json:"status"`
+}
+
+// SnapshotCreateResponse is the response of SnapshotCreateService.Do.
+type SnapshotCreateResponse struct {
+ // Accepted indicates whether the request was accepted by elasticsearch.
+ // It's available when waitForCompletion is false.
+ Accepted *bool `json:"accepted"`
+
+ // Snapshot is available when waitForCompletion is true.
+ Snapshot *struct {
+ Snapshot string `json:"snapshot"`
+ UUID string `json:"uuid"`
+ VersionID int `json:"version_id"`
+ Version string `json:"version"`
+ Indices []string `json:"indices"`
+ State string `json:"state"`
+ Reason string `json:"reason"`
+ StartTime time.Time `json:"start_time"`
+ StartTimeInMillis int64 `json:"start_time_in_millis"`
+ EndTime time.Time `json:"end_time"`
+ EndTimeInMillis int64 `json:"end_time_in_millis"`
+ DurationInMillis int64 `json:"duration_in_millis"`
+ Failures []SnapshotShardFailure `json:"failures"`
+ Shards shardsInfo `json:"shards"`
+ } `json:"snapshot"`
+}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/snapshot_create_test.go b/vendor/gopkg.in/olivere/elastic.v5/snapshot_create_test.go
new file mode 100644
index 000000000..d3fafc50d
--- /dev/null
+++ b/vendor/gopkg.in/olivere/elastic.v5/snapshot_create_test.go
@@ -0,0 +1,63 @@
+package elastic
+
+import (
+ "net/url"
+ "reflect"
+ "testing"
+)
+
+func TestSnapshotValidate(t *testing.T) {
+ var client *Client
+
+ err := NewSnapshotCreateService(client).Validate()
+ got := err.Error()
+ expected := "missing required fields: [Repository Snapshot]"
+ if got != expected {
+ t.Errorf("expected %q; got: %q", expected, got)
+ }
+}
+
+func TestSnapshotPutURL(t *testing.T) {
+ client := setupTestClient(t)
+
+ tests := []struct {
+ Repository string
+ Snapshot string
+ Pretty bool
+ MasterTimeout string
+ WaitForCompletion bool
+ ExpectedPath string
+ ExpectedParams url.Values
+ }{
+ {
+ Repository: "repo",
+ Snapshot: "snapshot_of_sunday",
+ Pretty: true,
+ MasterTimeout: "60s",
+ WaitForCompletion: true,
+ ExpectedPath: "/_snapshot/repo/snapshot_of_sunday",
+ ExpectedParams: url.Values{
+ "pretty": []string{"1"},
+ "master_timeout": []string{"60s"},
+ "wait_for_completion": []string{"true"},
+ },
+ },
+ }
+
+ for _, test := range tests {
+ path, params, err := client.SnapshotCreate(test.Repository, test.Snapshot).
+ Pretty(test.Pretty).
+ MasterTimeout(test.MasterTimeout).
+ WaitForCompletion(test.WaitForCompletion).
+ buildURL()
+ if err != nil {
+ t.Fatal(err)
+ }
+ if path != test.ExpectedPath {
+ t.Errorf("expected %q; got: %q", test.ExpectedPath, path)
+ }
+ if !reflect.DeepEqual(params, test.ExpectedParams) {
+ t.Errorf("expected %q; got: %q", test.ExpectedParams, params)
+ }
+ }
+}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/suggester_completion.go b/vendor/gopkg.in/olivere/elastic.v5/suggester_completion.go
index df6086e63..1da6063a6 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/suggester_completion.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/suggester_completion.go
@@ -123,7 +123,7 @@ func (q *CompletionSuggester) Source(includeName bool) (interface{}, error) {
ctxq[k] = v
}
}
- suggester["context"] = ctxq
+ suggester["contexts"] = ctxq
}
// TODO(oe) Add completion-suggester specific parameters here
diff --git a/vendor/gopkg.in/olivere/elastic.v5/suggester_completion_test.go b/vendor/gopkg.in/olivere/elastic.v5/suggester_completion_test.go
index 6b7c3f420..6bffddfe7 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/suggester_completion_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/suggester_completion_test.go
@@ -45,8 +45,8 @@ func TestCompletionSuggesterSourceWithMultipleContexts(t *testing.T) {
t.Fatalf("marshaling to JSON failed: %v", err)
}
got := string(data)
- expected := `{"song-suggest":{"text":"n","completion":{"context":{"artist":"Sting","label":"BMG"},"field":"suggest"}}}`
+ expected := `{"song-suggest":{"text":"n","completion":{"contexts":{"artist":[{"context":"Sting"}],"label":[{"context":"BMG"}]},"field":"suggest"}}}`
if got != expected {
- t.Errorf("expected\n%s\n,got:\n%s", expected, got)
+ t.Errorf("expected %s\n,got:\n%s", expected, got)
}
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/suggester_context_category.go b/vendor/gopkg.in/olivere/elastic.v5/suggester_context_category.go
index c224ae04a..2d63fe8fb 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/suggester_context_category.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/suggester_context_category.go
@@ -62,23 +62,36 @@ func (q *SuggesterCategoryMapping) Source() (interface{}, error) {
// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/suggester-context.html#_category_query.
type SuggesterCategoryQuery struct {
name string
- values []string
+ values map[string]*int
}
// NewSuggesterCategoryQuery creates a new SuggesterCategoryQuery.
func NewSuggesterCategoryQuery(name string, values ...string) *SuggesterCategoryQuery {
q := &SuggesterCategoryQuery{
name: name,
- values: make([]string, 0),
+ values: make(map[string]*int),
}
+
if len(values) > 0 {
- q.values = append(q.values, values...)
+ q.Values(values...)
}
return q
}
+func (q *SuggesterCategoryQuery) Value(val string) *SuggesterCategoryQuery {
+ q.values[val] = nil
+ return q
+}
+
+func (q *SuggesterCategoryQuery) ValueWithBoost(val string, boost int) *SuggesterCategoryQuery {
+ q.values[val] = &boost
+ return q
+}
+
func (q *SuggesterCategoryQuery) Values(values ...string) *SuggesterCategoryQuery {
- q.values = append(q.values, values...)
+ for _, val := range values {
+ q.values[val] = nil
+ }
return q
}
@@ -88,11 +101,18 @@ func (q *SuggesterCategoryQuery) Source() (interface{}, error) {
switch len(q.values) {
case 0:
- source[q.name] = q.values
- case 1:
- source[q.name] = q.values[0]
+ source[q.name] = make([]string, 0)
default:
- source[q.name] = q.values
+ contexts := make([]interface{}, 0)
+ for val, boost := range q.values {
+ context := make(map[string]interface{})
+ context["context"] = val
+ if boost != nil {
+ context["boost"] = *boost
+ }
+ contexts = append(contexts, context)
+ }
+ source[q.name] = contexts
}
return source, nil
diff --git a/vendor/gopkg.in/olivere/elastic.v5/suggester_context_category_test.go b/vendor/gopkg.in/olivere/elastic.v5/suggester_context_category_test.go
index 3a013d642..46acd725e 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/suggester_context_category_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/suggester_context_category_test.go
@@ -73,7 +73,7 @@ func TestSuggesterCategoryQuery(t *testing.T) {
t.Fatalf("marshaling to JSON failed: %v", err)
}
got := string(data)
- expected := `{"color":"red"}`
+ expected := `{"color":[{"context":"red"}]}`
if got != expected {
t.Errorf("expected\n%s\n,got:\n%s", expected, got)
}
@@ -90,8 +90,74 @@ func TestSuggesterCategoryQueryWithTwoValues(t *testing.T) {
t.Fatalf("marshaling to JSON failed: %v", err)
}
got := string(data)
- expected := `{"color":["red","yellow"]}`
- if got != expected {
- t.Errorf("expected\n%s\n,got:\n%s", expected, got)
+ expectedOutcomes := []string{
+ `{"color":[{"context":"red"},{"context":"yellow"}]}`,
+ `{"color":[{"context":"yellow"},{"context":"red"}]}`,
+ }
+ var match bool
+ for _, expected := range expectedOutcomes {
+ if got == expected {
+ match = true
+ break
+ }
+ }
+ if !match {
+ t.Errorf("expected any of %v\n,got:\n%s", expectedOutcomes, got)
+ }
+}
+
+func TestSuggesterCategoryQueryWithBoost(t *testing.T) {
+ q := NewSuggesterCategoryQuery("color", "red")
+ q.ValueWithBoost("yellow", 4)
+ src, err := q.Source()
+ if err != nil {
+ t.Fatal(err)
+ }
+ data, err := json.Marshal(src)
+ if err != nil {
+ t.Fatalf("marshaling to JSON failed: %v", err)
+ }
+ got := string(data)
+ expectedOutcomes := []string{
+ `{"color":[{"context":"red"},{"boost":4,"context":"yellow"}]}`,
+ `{"color":[{"boost":4,"context":"yellow"},{"context":"red"}]}`,
+ }
+ var match bool
+ for _, expected := range expectedOutcomes {
+ if got == expected {
+ match = true
+ break
+ }
+ }
+ if !match {
+ t.Errorf("expected any of %v\n,got:\n%v", expectedOutcomes, got)
+ }
+}
+
+func TestSuggesterCategoryQueryWithoutBoost(t *testing.T) {
+ q := NewSuggesterCategoryQuery("color", "red")
+ q.Value("yellow")
+ src, err := q.Source()
+ if err != nil {
+ t.Fatal(err)
+ }
+ data, err := json.Marshal(src)
+ if err != nil {
+ t.Fatalf("marshaling to JSON failed: %v", err)
+ }
+ got := string(data)
+ expectedOutcomes := []string{
+ `{"color":[{"context":"red"},{"context":"yellow"}]}`,
+ `{"color":[{"context":"yellow"},{"context":"red"}]}`,
+ }
+ var match bool
+ for _, expected := range expectedOutcomes {
+ if got == expected {
+ match = true
+ break
+ }
+ }
+ if !match {
+ t.Errorf("expected any of %v\n,got:\n%s", expectedOutcomes, got)
}
}
diff --git a/vendor/gopkg.in/olivere/elastic.v5/update.go b/vendor/gopkg.in/olivere/elastic.v5/update.go
index e139f8108..67dafc700 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/update.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/update.go
@@ -283,10 +283,12 @@ func (b *UpdateService) Do(ctx context.Context) (*UpdateResponse, error) {
// UpdateResponse is the result of updating a document in Elasticsearch.
type UpdateResponse struct {
- Index string `json:"_index"`
- Type string `json:"_type"`
- Id string `json:"_id"`
- Version int `json:"_version"`
- Created bool `json:"created"`
- GetResult *GetResult `json:"get"`
+ Index string `json:"_index"`
+ Type string `json:"_type"`
+ Id string `json:"_id"`
+ Version int `json:"_version"`
+ Shards *shardsInfo `json:"_shards"`
+ Result bool `json:"string,omitempty"`
+ ForcedRefresh bool `json:"forced_refresh,omitempty"`
+ GetResult *GetResult `json:"get,omitempty"`
}