учитывая, что этот запрос может выполняться в инструментах разработки Elasticsearch и документах обновления
Код: Выделить всё
@Slf4j
@Service
@RequiredArgsConstructor
public class ElasticsearchBulkUpdateService {
private final ElasticsearchOperations elasticsearchOperations;
public void updateProfitForPattern(String idPattern, String indexName) {
log.info("Executing simple query on index '{}':", indexName);
Query query = new StringQuery("""
{
"query": {
"wildcard": {
"id": {
"value": "*-14030701"
}
}
},
"script": {
"source": "
if (ctx._source.fundUnit != null) {
ctx._source.profit = ctx._source.fundUnit * 5;
}
",
"lang": "painless"
}
}
""");
UpdateQuery searchQuery = UpdateQuery.builder(query).build();
IndexCoordinates indexCoordinates = IndexCoordinates.of(indexName);
ByQueryResponse byQueryResponse = elasticsearchOperations.updateByQuery(searchQuery, indexCoordinates);
System.err.println(byQueryResponse);
}
}
org.springframework.data.elasticsearch.UncategorizedElasticsearchException: [es/update_by_query] не удалось : [parsing_Exception] неизвестный запрос [запрос]
Похоже, что запрос Elasticsearch распознается неправильно. Я использую Spring Data Elasticsearch с ElasticsearchOperations. Может ли кто-нибудь указать, что я делаю неправильно или как я могу решить эту проблему?
Версия весенней загрузки: 3.2.5
spring-boot-starter-data-elasticsearch Версия : 5.2.5
Подробнее здесь: https://stackoverflow.com/questions/790 ... ry-query-w