VanRoy/spring-data-jest

retry_on_conflict parameter on update query

bpuertolas opened this issue · 2 comments

The parameter retry_on_conflits is not applied with this code:

   IndexRequest indexRequest = new IndexRequest().source(objectMapper.convertValue(document, Map.class));
    UpdateQuery updateQuery = new UpdateQueryBuilder()
      .withId(document.getId())
      .withClass(ElasticsearchTraceDocument.class)
      .withIndexRequest(indexRequest)
      .withDoUpsert(true).build();
    updateQuery.getUpdateRequest().retryOnConflict(5);
    elasticsearchOperations.update(updateQuery);

I manage to do it without spring-data-jest (directly with io.searchbox.client.JestClient) with this code :

    Map<String, Object> payLoadMap = new HashMap<>();
    payLoadMap.put("doc_as_upsert", Boolean.TRUE);
    payLoadMap.put("doc", objectMapper.convertValue(document, Map.class));
    String payload;
    try {
      payload = objectMapper.writeValueAsString(payLoadMap);
    } catch (JsonProcessingException e) {
      logger.error("Error while writing Elasticsearch upsert document as String", e);
      return;
    }
    Update update = new Update.Builder(payload)
      .id(document.getId())
      .index(indexName)
      .setParameter("retry_on_conflict", 6)
      .type("elasticsearchtracedocument")
      .build();
    try {
      jestClient.execute(update);
    } catch (IOException e) {
      logger.error("Error while saving or updating a trace document", e);
    }

@nouarf Thanks for the report and sorry for the delay. I'll try to integrate it quickly.

Fixed in release 3.3.2.RELASE