ElasticSearch中未初始化的常量faraday::error::connectionfailed

wgeznvg7  于 2021-06-14  发布在  ElasticSearch
关注(0)|答案(1)|浏览(508)

我将通过以下教程在rails中实现ElasticSearch
https://iridakos.com/programming/2017/12/03/elasticsearch-and-rails-tutorial
并将这些行添加到my user.rb include Elasticsearch::Model include Elasticsearch::Model::Callbacks &还安装了这两个宝石 gem 'elasticsearch-model' gem 'elasticsearch-rails' 但是当我试图执行这个命令 Post.import(force: true) 它给了我一个错误
未初始化的常量faraday::error::connectionfailed

eivnm1vs

eivnm1vs1#

是的,最后我找到了解决方案,因为我的项目是一个停靠的项目&我在本地运行elasticsearch,这就是为什么我的应用程序没有与elasticsearch连接。
当我在docker-compose.yml中添加了所有凭据后,从docker图像中提取并运行elasticsearch时,我成功地实现了它。
注意:你的kibana和elasticsearch版本应该是相同的。
我的docker-compose.yml

services: 

## My all services

elasticsearch:
      image: docker.elastic.co/elasticsearch/elasticsearch:6.8.13
      environment:
        - cluster.name=docker-cluster
        - bootstrap.memory_lock=true
        - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
        - xpack.security.enabled=false
        - xpack.monitoring.enabled=false
        - xpack.graph.enabled=false
        - xpack.watcher.enabled=false
        - discovery.type=single-node
      ulimits:
        memlock:
          soft: -1
          hard: -1
      networks:
        - eb-back_network
      volumes:
        - ./docker_data/elasticsearch/data:/usr/share/elasticsearch/data
      ports:
        - "9200:9200"
        - "9300:9300"

kibana:
    image: docker.elastic.co/kibana/kibana:6.8.13
    restart: always
    volumes:
      - ./kibana.yml:/usr/share/kibana/config/kibana.yml
    environment:
      - ELASTICSEARCH_HOSTS=http://elasticsearch:9200
    ports:
      - "5601:5601"
    networks:
      - eb-back_network
    depends_on:
      - elasticsearch

相关问题