Я пытаюсь реализовать простую операцию CRUD в Elasticsearch, используя groovy и grails какое-то время я могу создать индекс, и какое-то время я получаю нижеупомянутое исключение, которое истекает, я пробовал несколько способов, ни один из них не работает. Я застрял здесь, может помочь мне выбраться из этого. * ниже исключения я прикрепил код, который использую здесь, просмотрите его и проверьте, верен ли он или нет
Исключение
Error |2018-05-29 23:13:18,320 [http-bio-8080-exec-10] ERROR errors.GrailsExceptionResolver - IOException occurred when processing request: [GET] /Sharama1/person/addPerson listener timeout after waiting fo List item r [30000] ms. Stacktrace follows: Message: listener timeout after waiting for [30000] ms Line | Method ->> 661 | get in org.elasticsearch.client.RestClient$SyncResponseListener - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 220 | performRequest in org.elasticsearch.client.RestClient | 192 | performRequest . . . . . . . . . . . in '' | 428 | performRequest in org.elasticsearch.client.RestHighLevelClient | 414 | performRequestAndParseEntity . . . . in '' | 299 | index in '' | -2 | invoke0 . . . . . . . . . . . . . . . in sun.reflect.NativeMethodAccessorImpl | 62 | invoke in '' | 43 | invoke . . . . . . . . . . . . . . . in sun.reflect.DelegatingMethodAccessorImpl | 497 | invoke in java.lang.reflect.Method | 1426 | jlrMethodInvoke . . . . . . . . . . . in org.springsource.loaded.ri.ReflectiveInterceptor | 189 | invoke in org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoCachedMethodSite
* создать индексный код *
def addPerson = {
RestHighLevelClient client=ESService.getClient()
Map<String,Object> jsonMap = new HashMap<>();
jsonMap.put("firstName","abcd");
jsonMap.put("lastName","xyz");
jsonMap.put("date",new Date());
jsonMap.put("message","Hugh data Index mapping");
IndexRequest indexRequest = new IndexRequest("person1","hughdata","4").source(jsonMap);
IndexResponse res = client.index(indexRequest);
String index = res.getIndex()
String type = res.getType()
String id = res.id
long version = res.getVersion()
DocWriteResponse.Result result = res.getResult();
if (result == DocWriteResponse.Result.CREATED){
println("index created = "+result)
}
else if (result == DocWriteResponse.Result.UPDATED){
println("index Updated = "+result)
}
["index":index,"type": type,"id":id,"version":version]
}
Создать клиентский код
class ESService {
RestHighLevelClient client=null
//TransportClient client=null
def RestHighLevelClient getClient(){
try {
String hostname = "localhost"
int port = 9200
String scheme = "http"
client = new RestHighLevelClient(RestClient.builder(new HttpHost("localhost",9200,"http")))
boolean pingResponse = client.ping()
if (pingResponse == true) {
print("connection established..." + pingResponse);
} else {
print("connection not established. Try again : " + pingResponse)
}
/*return client*/
}
catch (ElasticsearchException e){
e.printStackTrace()
}
return client
}
}
Buildconfig.groovy
dependencies {
// specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes e.g.
// runtime 'mysql:mysql-connector-java:5.1.27'
// runtime 'org.postgresql:postgresql:9.3-1100-jdbc41'
test "org.grails:grails-datastore-test-support:1.0-grails-2.3"
compile group: 'org.elasticsearch', name: 'elasticsearch', version: '6.0.1'
compile group: 'org.elasticsearch.client', name: 'elasticsearch-rest-high-level-client', version: '6.0.1'
compile('com.amazonaws:aws-java-sdk-elasticsearch:1.11.123')
compile('com.amazonaws:aws-java-sdk-elasticloadbalancingv2:1.11.123')
}
Не по теме: Пожалуйста, привыкните заканчивать каждую строку команды точкой с запятой ;. Ваш код - настоящий беспорядок.
[GET] / Sharama1 / - мой URL-адрес по умолчанию, добавлен persosn / addPerson к URL-адресу по умолчанию, чтобы вызвать действие addPerson
в Groovy не обязательно ставить точку с запятой в конце строки (; в Groovy необязательно)




[GET] /Sharama1/person/addPerson. Откуда этот звонок?