Reputation: 21
I'm using Elastic Java API in Scala to delete a list of document, using their ID to delete them one at a time, no success for now. API works fine for other calls like SearchResponse.
My code looks like this :
var deleteResp : DeleteResponse = null
deleteResp = ElasticSearch.getClient()
.prepareDelete(index, type, id)
.get()
Same with :
deleteResp = ElasticSearch.getClient()
.prepareDelete(index, type, id)
.execute()
.actionGet()
I also tried to catch Elastic response for debugging using this, but nothing shows up in stdout.
try{ \ previous code }
catch {
case e: Exception => {
print("Failed deletion", e.getMessage)
e.printStackTrace() }
}
Config :
- Scala 2.10.6
- Spark 1.6
- Elasticsearch 2.3.2
Thank you
Upvotes: 1
Views: 1056
Reputation: 21
I guess it's a pretty specific case but given the poor info on Java API usage, someone may find this case relevant.
Thank to Val and precise debugging I found the cause : Be very careful on the string format passed to the prepareSearch().
My ID, coming from a List, contained brackets that messed things up, the delete request was successful but on a wrong ID.
For details, think about using all available methods on request objects and double check each formatting :
var deletedId = deleteResp.getId()
var deletedType = deleteResp.getType()
var deletedIndex = deleteResp.getIndex()
var deletedShard = deleteResp.getShardInfo()
Upvotes: 1