Handling errors in bulk indexing. There is a filed named erros which indicates whether commit was succesful see: http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/bulk.html
This commit is contained in:
		
							parent
							
								
									7a0373c858
								
							
						
					
					
						commit
						c4d6ac023a
					
				
							
								
								
									
										11
									
								
								goes.go
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								goes.go
									
									
									
									
									
								
							| @ -350,6 +350,17 @@ func (req *Request) Run() (Response, error) { | ||||
| 		return Response{}, err | ||||
| 	} | ||||
| 
 | ||||
| 	if req.api == "_bulk" && esResp.Errors { | ||||
| 		for _, item := range esResp.Items { | ||||
| 			for _, i := range item { | ||||
| 				if i.Error != "" { | ||||
| 					return Response{}, &SearchError{i.Error, i.Status} | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 		return Response{}, &SearchError{Msg: "Unknown error while bulk indexing"} | ||||
| 	} | ||||
| 
 | ||||
| 	if esResp.Error != "" { | ||||
| 		return Response{}, &SearchError{esResp.Error, esResp.Status} | ||||
| 	} | ||||
|  | ||||
| @ -59,6 +59,7 @@ type Request struct { | ||||
| type Response struct { | ||||
| 	Acknowledged bool | ||||
| 	Error        string | ||||
| 	Errors       bool | ||||
| 	Status       uint64 | ||||
| 	Took         uint64 | ||||
| 	TimedOut     bool  `json:"timed_out"` | ||||
| @ -111,6 +112,8 @@ type Item struct { | ||||
| 	Id      string `json:"_id"` | ||||
| 	Index   string `json:"_index"` | ||||
| 	Version int    `json:"_version"` | ||||
| 	Error   string `json:"error"` | ||||
| 	Status  uint64 `json:"status"` | ||||
| } | ||||
| 
 | ||||
| // Represents the "_all" field when calling the _stats API
 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user