RestClient Builder отправляет ответ на 9201 вместо 9200 - PullRequest
0 голосов
/ 18 сентября 2018

При попытке загрузить данные (строка в формате JSON) в ElasticSearch (версия 6.3.1), оставшийся клиент отправляет ответ на 9201 вместо 9200, даже когда я не упомянул 9201. Ссылка

Вот код, который я использую для настройки RestClient -

private static void restWorkPUT() throws IOException {

    RestClient restClient = RestClient.builder(
            new HttpHost("localhost", 9200, "http")
            ).build();

    jsonDataToUpload = "{\n" + "    \"user\" : \"kimchy\",\n" + "    \"post_date\" : \"2009-11-15T14:12:12\",\n"
                            + "    \"message\" : \"trying out Elasticsearch\"\n" + "}";

    HttpEntity entity = new NStringEntity(jsonWithIndex,
            ContentType.APPLICATION_JSON);

    Response indexResponse = restClient.performRequest("POST", "/testabc/abc/1", Collections.<String, String>emptyMap(), entity);

}

Теперь, когда я нажимаю http://localhost:9200/testabc/abc/1,, я вижу ответ

{
    "error": {
    "root_cause": [
    {
    "type": "index_not_found_exception",
    "reason": "no such index",
    "resource.type": "index_expression",
    "resource.id": "testabc",
    "index_uuid": "_na_",
    "index": "testabc"
    }
    ],
    "type": "index_not_found_exception",
    "reason": "no such index",
    "resource.type": "index_expression",
    "resource.id": "testabc",
    "index_uuid": "_na_",
    "index": "testabc"
    },
    "status": 404
}

Когда я нажимаю http://localhost:9201/testabc/abc/1,, я вижу ответ -

{
"_index": "testabc",
"_type": "abc",
"_id": "1",
"_version": 4,
"found": true,
"_source": {
"user": "kimchy",
"post_date": "2009-11-15T14:12:12",
"message": "trying out Elasticsearch"
}
}

Я хочу иметь возможность загружать данные JSON в Kibana / ElasticSearch, который размещен на 9200.

Любые предложения по выяснению, как это исправить, будут оценены.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...