Я создал сервис Java для elasti c Операция поиска CRUD. Ниже я предоставил свои бизнес-логи c. Я делаю все проверки на стороне сервера, так как мне нужно проверить поиск elasti c. В настоящее время развертывание доступно или не используется с помощью поиска RestHighLevelClient из elasti c перед вставкой данных в мой индекс. я дал свой код ниже.
public String createProfileDocument(EmployeeInformation document, String IndexName) throws Exception {
String Id = document.getId();
if (Strings.isNullOrEmpty(Id)) {
return "ID is null or empty";
}
else if(Strings.isNullOrEmpty(IndexName)) {
return "Index name is null or empty";
}
else if(isTextContainUpperCase(IndexName)){
return "Index name should be in lowercase";
}
else if(logic to check the deployment)
{
return "Elasticsearch deployment is not reachable";
}
IndexRequest indexRequest = new IndexRequest(IndexName);
indexRequest.id(document.getId());
indexRequest.source(convertProfileDocumentToMap(document), XContentType.JSON);
IndexResponse indexResponse = client.index(indexRequest, RequestOptions.DEFAULT);
return indexResponse.getResult().name();
}
Может ли кто-нибудь помочь мне добиться этого в приведенном выше коде? Заранее спасибо