Closed naidusana closed 1 week ago
Please provide a minimal compilable and runnable example that reproduces this error and a complete stacktrace.
Hi, Please find below details
Springboot: 2.7.1 Spring Data elastic search: 4.4.1 Rest High Level Client : 7.17.5
Elastic Cluster: 8.10.3
@Configuration public class ElasticsearchConfig extends AbstractElasticsearchConfiguration{
@Bean
@Override
public RestHighLevelClient elasticsearchClient() {
ElasticsearchProperty esProp = elasticsearchProperty();
HttpHeaders compatibilityHeaders = new HttpHeaders();
compatibilityHeaders.add(DataFlowConstants.ACCEPT, "application/vnd.elasticsearch+json;compatible-with=7);
compatibilityHeaders.add(DataFlowConstants.CONTENT_TYPE, "application/vnd.elasticsearch+json;compatible-with=7);
ClientConfiguration clientConfiguration = ClientConfiguration.builder()
.connectedTo("url")
.withBasicAuth("username", "password")
.withDefaultHeaders(compatibilityHeaders)
.withConnectTimeout(5000)
.withSocketTimeout(5000)
.build();
RestHighLevelClient restClient = RestClients.create(clientConfiguration).rest();
return restClient;
}
}
SpringBoot: 3.1.10 Spring Data Elastic search: 5.1.10
Elastic Cluster: 8.10.3
@Configuration public class ElasticsearchConfig extends ElasticsearchConfiguration {
@NotNull
public ClientConfiguration clientConfiguration() {
ElasticsearchProperty esProp = elasticsearchProperty();
HttpHeaders compatibilityHeaders = new HttpHeaders();
return ClientConfiguration.builder()
.connectedTo("url")
.withBasicAuth("username", "password")
.withDefaultHeaders(compatibilityHeaders)
.withConnectTimeout(5000)
.withSocketTimeout(5000)
.build();
}
}
import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.elasticsearch.core.ElasticsearchOperations; import org.springframework.data.elasticsearch.core.RefreshPolicy; import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates; import org.springframework.data.elasticsearch.core.query.BulkOptions; import org.springframework.data.elasticsearch.core.query.UpdateQuery;
import java.time.Duration; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map;
public class Test { @Autowired private static ElasticsearchOperations esOps;
public static void main(String[] args) {
List<Map<String, Map<String, Object>>> dataList = new ArrayList<>();
Map<String, Map<String, Object>> scriptMap = new HashMap<>();
Map<String, Object> map = new HashMap<>();
map.put("ID", "ID1");
map.put("NAME", "NAME1");
scriptMap.put("ctx._source.NAME=params.NAME;", map);
Map<String, Object> map1 = new HashMap<>();
map1.put("ID", "ID2");
map1.put("NAME", "NAME2");
scriptMap.put("ctx._source.NAME=params.NAME;", map1);
dataList.add(scriptMap);
updateAllByScript("index", dataList, "ID", false);
}
public static void updateAllByScript(String indexName, List<Map<String, Map<String, Object>>> dataList, String idFieldName, boolean isRefresh) {
List<UpdateQuery> updateQueries = new ArrayList<>();
for (Map<String, Map<String, Object>> map : dataList) {
for (Map.Entry<String, Map<String, Object>> e : map.entrySet()) {
if (StringUtils.isNotBlank(e.getKey()) && e.getValue() != null) {
String id = String.valueOf(e.getValue().get(idFieldName));
UpdateQuery updateQuery = UpdateQuery.builder(id)
.withScript(e.getKey())
.withParams(e.getValue())
.build();
updateQueries.add(updateQuery);
}
}
BulkOptions.BulkOptionsBuilder bulkOptionsBuilder = BulkOptions.builder();
bulkOptionsBuilder.withTimeout(Duration.ofMillis(5000));
if (isRefresh) {
bulkOptionsBuilder.withRefreshPolicy(RefreshPolicy.IMMEDIATE);
}
BulkOptions bulkOptions = bulkOptionsBuilder.build();
esOps.bulkUpdate(updateQueries, bulkOptions, IndexCoordinates.of(indexName));
}
}
}
Above example working fine in before upgrade and after upgrade getting below exception
co.elastic.clients.util.MissingRequiredPropertyException: Missing required property 'Builder.
As I wrote:
Please provide a minimal compilable and runnable example that reproduces this error
I do not have the time to create a project to add this code to to be able to reproduce or debug this error.
And notice that the version you use (5.1.x) is outdated and not maintained anymore. So please first check if this error still occurs with the current 5.3 release of Spring Data Elasticsearch.
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.
Spring data elastic bulkUpdate giving below error
Exception: co.elastic.clients.util.MissingRequiredPropertyException: Missing required property 'Builder.'
Code:
List updateQueries = new ArrayList<>();
for(Map<String, Map<String, Object>> map : dataList) {
for(Entry<String, Map<String, Object>> e : map.entrySet()) {
if(StringUtils.isNotBlank(e.getKey()) && e.getValue() != null) {
String id = String.valueOf(e.getValue().get(idFieldName));
UpdateQuery updateQuery = UpdateQuery.builder(id)
.withScript(e.getKey())
.withParams(e.getValue())
.build();
updateQueries.add(updateQuery);
}
}
}
BulkOptionsBuilder bulkOptionsBuilder = BulkOptions.builder();
bulkOptionsBuilder.withTimeout(Duration.ofMillis(5000));
if(isRefresh) {
bulkOptionsBuilder.withRefreshPolicy(RefreshPolicy.IMMEDIATE);
}
BulkOptions bulkOptions = bulkOptionsBuilder.build();
SpringBoor: 3.1.10 data elastic search : 5.1.10