В настоящее время я использую эластичный поиск и версию 7.0.0 kibana с файлом docker compose в моем проекте
version: '3.4'
services:
search.api:
image: ${DOCKER_REGISTRY-}searchapi
build:
context: .
dockerfile: Search.API/Dockerfile
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.0.0
container_name: elasticsearch
environment:
- discovery.type=single-node
- cluster.name=docker-cluster
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
memlock:
soft: -1
hard: -1
ports:
- "9200:9200"
- "9300:9300"
volumes:
- es_data:/elasticsearch/data
networks:
- esnetwork
kibana:
image: docker.elastic.co/kibana/kibana:7.0.0
container_name: kibana
environment:
- "ELASTICSEARCH_URL=http://elasticsearch:9200"
ports:
- "5601:5601"
networks:
- esnetwork
depends_on:
- elasticsearch
networks:
esnetwork:
driver: bridge
volumes:
es_data:
Я могу подключиться к kibana через порт 5601 (индекс и данные поиска), а также выполнить упругий поиск по порту 9200.
Я пытаюсь использовать NEST для подключения к эластичному. Вот моя базовая конфигурация
public static IServiceCollection AddElasticsearch(this IServiceCollection services, IConfiguration configuration)
{
var settings = new ConnectionSettings(new Uri("http://localhost:9200"));
var client = new ElasticClient(settings);
var pingResponse = client.Ping(new PingRequest());
Log.Debug("Ping client {0}",pingResponse);
services.AddSingleton<IElasticClient>(client);
return services;
}
Я получаю следующее исключение при выполнении какой-либо команды через NEST, такой как ping, healthcheck или поиск и т. Д., Это наводит меня на мысль, что есть некоторая проблема, связанная с сетью, в док-контейнерах (контейнерах Linux), но я в настоящий момент в тупике
Invalid NEST response built from a unsuccessful low level call on POST: /clients/_search?typed_keys=true
# Audit trail of this API call:
- [1] BadRequest: Node: http://localhost:9200/ Took: 00:00:00.8555510
# OriginalException: System.Net.Http.HttpRequestException: Cannot assign requested address ---> System.Net.Sockets.SocketException: Cannot assign requested address
at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
at System.Threading.Tasks.ValueTask`1.get_Result()
at System.Net.Http.HttpConnectionPool.CreateConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Threading.Tasks.ValueTask`1.get_Result()
at System.Net.Http.HttpConnectionPool.WaitForCreatedConnectionAsync(ValueTask`1 creationTask)
at System.Threading.Tasks.ValueTask`1.get_Result()
at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
at Elasticsearch.Net.HttpConnection.RequestAsync[TResponse](RequestData requestData, CancellationToken cancellationToken)
# Request:
<Request stream not captured or already read to completion by serializer. Set DisableDirectStreaming() on ConnectionSettings to force it to be set on the response.>
# Response:
<Response stream not captured or already read to completion by serializer. Set DisableDirectStreaming() on ConnectionSettings to force it to be set on the response.>