Код: Выделить всё
import org.opensearch.client.opensearch.OpenSearchClient;
import org.opensearch.client.opensearch.core.GetResponse;
private OpenSearchClient client;
private Optional getDocumentResponse(BaseIndexDto request, String... indices) {
try {
final String indexName = this.getIndexName(indices);
GetRequest getRequest = new GetRequest.Builder()
.index(indexName)
.id(request.getId())
.build();
GetResponse response = client.get(getRequest, GetResponse.class);
if (response.found()) {
return Optional.of(response);
} else {
return Optional.empty();
}
} catch (Exception e) {
throw Exception("Error");
}
}
Код: Выделить всё
private Optional getDocumentResponse(BaseIndexDto request, String... indices) {
try {
final String indexName = this.getIndexName(indices);
GetRequest getRequest = new GetRequest.Builder()
.index(indexName)
.id(request.getId())
.build();
GetResponse response = client.get(getRequest, GetResponse.class);
if (response.found()) {
return Optional.of(response);
} else {
return Optional.empty();
}
} catch (Exception e) {
throw Exception("Error");
}
}
Код: Выделить всё
Required type: GetResponse
Provided: GetResponse
Incompatible equality constraint: Map and GetResponse
Код: Выделить всё
GetResponse response = client.get(getRequest, GetResponse.class);
Подробнее здесь: https://stackoverflow.com/questions/798 ... etresponse
Мобильная версия