elastic / elasticsearch-rs

Official Elasticsearch Rust Client
https://www.elastic.co/guide/en/elasticsearch/client/rust-api/current/index.html
Apache License 2.0
695 stars 70 forks source link

[BUG] Cannot use http transport to connect to docker containers #213

Open steventkrawczyk opened 1 year ago

steventkrawczyk commented 1 year ago

Describe the bug Because the Transport struct requires urls, you cannot pass the uri of a local docker container, which is a very common use case.

To Reproduce Create an ES node in docker compose like

  es:
    image: elasticsearch:8.6.0
    environment:
      - node.name=es
      - cluster.name=test
      - cluster.initial_master_nodes=es
      - bootstrap.memory_lock=true
      - xpack.security.enabled=false
    mem_limit: 1073741824
    ulimits:
      memlock:
        soft: -1
        hard: -1

and try to connect via Transport

let transport = Transport::single_node("es").unwrap();

Expected behavior Transport successfully connects to docker container.

liskin commented 1 year ago

Try the following which works for us quite well:

let transport = Transport::single_node("http://es:9200").unwrap();