removed index param from BulkSend

This commit is contained in:
Ian Babrou 2014-07-03 16:28:37 +04:00
parent cdd62356b9
commit 45e977fe8a
2 changed files with 8 additions and 9 deletions

View File

@ -100,9 +100,9 @@ func (c *Connection) IndexStatus(indexList []string) (Response, error) {
return r.Run() return r.Run()
} }
// Bulk adds multiple documents in bulk mode to the index for a given type // Bulk adds multiple documents in bulk mode
func (c *Connection) BulkSend(index string, documents []Document) (Response, error) { func (c *Connection) BulkSend(documents []Document) (Response, error) {
// We do not generate a traditionnal JSON here (often a one liner) // We do not generate a traditional JSON here (often a one liner)
// Elasticsearch expects one line of JSON per line (EOL = \n) // Elasticsearch expects one line of JSON per line (EOL = \n)
// plus an extra \n at the very end of the document // plus an extra \n at the very end of the document
// //
@ -160,7 +160,6 @@ func (c *Connection) BulkSend(index string, documents []Document) (Response, err
r := Request{ r := Request{
Conn: c, Conn: c,
IndexList: []string{index},
method: "POST", method: "POST",
api: "_bulk", api: "_bulk",
bulkData: bytes.Join(bulkData, []byte("\n")), bulkData: bytes.Join(bulkData, []byte("\n")),

View File

@ -195,7 +195,7 @@ func (s *GoesTestSuite) TestBulkSend(c *C) {
tweets := []Document{ tweets := []Document{
Document{ Document{
Id: "123", Id: "123",
Index: nil, Index: indexName,
Type: docType, Type: docType,
BulkCommand: BULK_COMMAND_INDEX, BulkCommand: BULK_COMMAND_INDEX,
Fields: map[string]interface{}{ Fields: map[string]interface{}{
@ -221,7 +221,7 @@ func (s *GoesTestSuite) TestBulkSend(c *C) {
_, err := conn.CreateIndex(indexName, nil) _, err := conn.CreateIndex(indexName, nil)
c.Assert(err, IsNil) c.Assert(err, IsNil)
response, err := conn.BulkSend(indexName, tweets) response, err := conn.BulkSend(tweets)
i := Item{ i := Item{
Id: "123", Id: "123",
Type: docType, Type: docType,
@ -277,7 +277,7 @@ func (s *GoesTestSuite) TestBulkSend(c *C) {
}, },
} }
response, err = conn.BulkSend(indexName, docToDelete) response, err = conn.BulkSend(docToDelete)
i = Item{ i = Item{
Id: "123", Id: "123",
Type: docType, Type: docType,
@ -681,7 +681,7 @@ func (s *GoesTestSuite) TestScroll(c *C) {
_, err := conn.CreateIndex(indexName, mapping) _, err := conn.CreateIndex(indexName, mapping)
c.Assert(err, IsNil) c.Assert(err, IsNil)
_, err = conn.BulkSend(indexName, tweets) _, err = conn.BulkSend(tweets)
c.Assert(err, IsNil) c.Assert(err, IsNil)
_, err = conn.RefreshIndex(indexName) _, err = conn.RefreshIndex(indexName)
@ -784,7 +784,7 @@ func (s *GoesTestSuite) TestAggregations(c *C) {
_, err := conn.CreateIndex(indexName, mapping) _, err := conn.CreateIndex(indexName, mapping)
c.Assert(err, IsNil) c.Assert(err, IsNil)
_, err = conn.BulkSend(indexName, tweets) _, err = conn.BulkSend(tweets)
c.Assert(err, IsNil) c.Assert(err, IsNil)
_, err = conn.RefreshIndex(indexName) _, err = conn.RefreshIndex(indexName)