Merge pull request #12 from bobrik/bulk-witout-index

Bulk witout index
This commit is contained in:
Jérôme Renard 2014-07-03 20:40:53 +02:00
commit 15921ffa9c
2 changed files with 25 additions and 27 deletions

View File

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

View File

@ -195,7 +195,7 @@ func (s *GoesTestSuite) TestBulkSend(c *C) {
tweets := []Document{
Document{
Id: "123",
Index: nil,
Index: indexName,
Type: docType,
BulkCommand: BULK_COMMAND_INDEX,
Fields: map[string]interface{}{
@ -221,7 +221,7 @@ func (s *GoesTestSuite) TestBulkSend(c *C) {
_, err := conn.CreateIndex(indexName, nil)
c.Assert(err, IsNil)
response, err := conn.BulkSend(indexName, tweets)
response, err := conn.BulkSend(tweets)
i := Item{
Id: "123",
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{
Id: "123",
Type: docType,
@ -681,7 +681,7 @@ func (s *GoesTestSuite) TestScroll(c *C) {
_, err := conn.CreateIndex(indexName, mapping)
c.Assert(err, IsNil)
_, err = conn.BulkSend(indexName, tweets)
_, err = conn.BulkSend(tweets)
c.Assert(err, IsNil)
_, err = conn.RefreshIndex(indexName)
@ -728,7 +728,6 @@ func (s *GoesTestSuite) TestScroll(c *C) {
c.Assert(len(searchResults.Hits.Hits), Equals, 0)
}
func (s *GoesTestSuite) TestAggregations(c *C) {
indexName := "testaggs"
docType := "tweet"
@ -784,7 +783,7 @@ func (s *GoesTestSuite) TestAggregations(c *C) {
_, err := conn.CreateIndex(indexName, mapping)
c.Assert(err, IsNil)
_, err = conn.BulkSend(indexName, tweets)
_, err = conn.BulkSend(tweets)
c.Assert(err, IsNil)
_, err = conn.RefreshIndex(indexName)