Skip to content
This repository was archived by the owner on Oct 18, 2021. It is now read-only.

deleteDocument API can fail with obscure error #141

Open
cddude229 opened this issue Oct 6, 2017 · 0 comments
Open

deleteDocument API can fail with obscure error #141

cddude229 opened this issue Oct 6, 2017 · 0 comments

Comments

@cddude229
Copy link
Contributor

new test:

    "Support deleting a doc that doesn't exist" in {
      val delFut = restClient.deleteDocument(index, tpe, new QueryRoot(TermQuery("text7", "here7")))
      Await.result(delFut, 10.seconds) // May not need Await?
    }

Failure mode:

- should Support deleting a doc that doesn't exist *** FAILED ***
  com.sumologic.elasticsearch.restlastic.RestlasticSearchClient$ReturnTypes$ElasticErrorResponse: ElasticsearchError(status=400): JString({"error":{"root_cause":[{"type":"parse_exception","reason":"Failed to derive xcontent"}],"type":"parse_exception","reason":"Failed to derive xcontent"},"status":400})
  at com.sumologic.elasticsearch.restlastic.RestlasticSearchClient$$anonfun$runRawEsRequest$1.apply(RestlasticSearchClient.scala:254)
  at com.sumologic.elasticsearch.restlastic.RestlasticSearchClient$$anonfun$runRawEsRequest$1.apply(RestlasticSearchClient.scala:249)
  at scala.util.Success$$anonfun$map$1.apply(Try.scala:237)
  at scala.util.Try$.apply(Try.scala:192)
  at scala.util.Success.map(Try.scala:237)
  at scala.concurrent.Future$$anonfun$map$1.apply(Future.scala:235)
  at scala.concurrent.Future$$anonfun$map$1.apply(Future.scala:235)
  at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:32)
  at scala.concurrent.impl.ExecutionContextImpl$AdaptedForkJoinTask.exec(ExecutionContextImpl.scala:121)
  at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
  ...

My best guess is it's this bit:

      val documents = Await.result(query(index, tpe, deleteQuery, rawJsonStr = false), 10.seconds).rawSearchResponse.hits.hits.map(_._id)
      bulkDelete(index, tpe, documents.map(Document(_, Map()))).map(res => RawJsonResponse(res.toString))

Looks like we fetch matching documents (0 matches) and then delete them. Some googling (elastic/elasticsearch#8595 (comment)) tells me that the Failure to derive xcontent occurs when the body is empty - so I think that's the issue here.

I'd correct it myself, but I'm not actually sure what to do in the case documents is empty since the return type is Future[RawJsonResponse]

I think this was a regression introduced in #126 btw. cc @CCheSumo

@cddude229 cddude229 changed the title deleteDocument API can fail with obscure errorN deleteDocument API can fail with obscure error Oct 6, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant