Skip to content

Commit

Permalink
Merge pull request #277 from j16r/feature/bulk_delete_request_parent
Browse files Browse the repository at this point in the history
Feature/bulk delete request parent
  • Loading branch information
olivere committed May 15, 2016
2 parents a8215e0 + 69df0c2 commit ef68337
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
9 changes: 9 additions & 0 deletions bulk_delete_request.go
Expand Up @@ -18,6 +18,7 @@ type BulkDeleteRequest struct {
index string
typ string
id string
parent string
routing string
refresh *bool
version int64 // default is MATCH_ANY
Expand All @@ -43,6 +44,11 @@ func (r *BulkDeleteRequest) Id(id string) *BulkDeleteRequest {
return r
}

func (r *BulkDeleteRequest) Parent(parent string) *BulkDeleteRequest {
r.parent = parent
return r
}

func (r *BulkDeleteRequest) Routing(routing string) *BulkDeleteRequest {
r.routing = routing
return r
Expand Down Expand Up @@ -87,6 +93,9 @@ func (r *BulkDeleteRequest) Source() ([]string, error) {
if r.id != "" {
deleteCommand["_id"] = r.id
}
if r.parent != "" {
deleteCommand["_parent"] = r.parent
}
if r.routing != "" {
deleteCommand["_routing"] = r.routing
}
Expand Down
6 changes: 6 additions & 0 deletions bulk_delete_request_test.go
Expand Up @@ -20,6 +20,12 @@ func TestBulkDeleteRequestSerialization(t *testing.T) {
`{"delete":{"_id":"1","_index":"index1","_type":"tweet"}}`,
},
},
{
Request: NewBulkDeleteRequest().Index("index1").Type("tweet").Id("1").Parent("2"),
Expected: []string{
`{"delete":{"_id":"1","_index":"index1","_parent":"2","_type":"tweet"}}`,
},
},
}

for i, test := range tests {
Expand Down

0 comments on commit ef68337

Please sign in to comment.