Closed debraj-manna closed 6 months ago
I was able to figure this out. The below is working fine.
NativeSearchQuery searchQuery =
new NativeSearchQueryBuilder()
.withQuery(QueryBuilders.termQuery("_id", doc.getKey()))
.withStoredFields(new String[] {"value"})
.build();
elasticsearchOperations.search(
searchQuery, KeyValueDoc.class, IndexCoordinates.of("request_response-*"));
Spring Data Elasticsearch's Query
implementations have a setStoredFields(List<String>)
method as well.
Sometimes I wonder why people use Spring Data Elasticsearch at all when they always create queries with the native Elasticsearch methods.
I have an index template like below
Can someone let me know how can I execute the below query using
spring-data-elasticsearch
?It returns the below result
I tried the below
But it is throwing the below error
I asked the same query in the Opensearch forum here and I was suggested raising the issue with
spring-data
team as it is not an issue with Opensearch or elastic search and spring-data should add this support.