Ruby 3 Rails 7 Solr 9 docker-compose 无法重新索引

问题描述 投票:0回答:1

在我的项目中,我遇到了 Ruby 3 Rails 7 Solr 9 的重新索引问题(使用 Sunspot gem)

这是我的

docker-compose.yml
文件

version: '3'

services:
  db:
    image: postgres
    volumes:
      - ./tmp/db:/var/lib/postgresql/data
    environment:
      POSTGRES_PASSWORD: password

  solr:
    image: solr:9.3.0
    ports:
      - "8983:8983"
    volumes:
      - search-data:/opt/solr/server/solr/mycores
    entrypoint:
      - docker-entrypoint.sh
      - solr-precreate
      - development
    depends_on:
      - db

  app:
    build: .
    command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails assets:precompile && bundle exec rails s -p 3000 -b '0.0.0.0'"
    volumes:
      - .:/app
      - bundle:/usr/local/bundle
      - tmp-data:/app/tmp
      - public-data:/app/public
    ports:
      - "3000:3000"
    depends_on:
      - db
      - solr

volumes:
  bundle:
  tmp-data:
  public-data:
  search-data:

我的

config/sunspot.yml

production:
  solr:
    hostname: solr
    solr_home: solr
    port: 8983
    log_level: WARNING
    path: /solr/production
    # read_timeout: 2
    # open_timeout: 0.5

development:
  solr:
    hostname: solr
    solr_home: solr
    port: 8983
    log_level: INFO
    path: /solr/development

test:
  solr:
    hostname: solr
    solr_home: solr
    port: 8983
    log_level: WARNING
    path: /solr/test

当我在

rake sunspot:solr:start
容器中运行
app
时:

# rake sunspot:solr:start
rake aborted!
Sunspot::Solr::Server::JavaMissing: You need a Java Runtime Environment to run the Solr server
/usr/local/bundle/gems/sunspot_solr-2.6.0/lib/sunspot/solr/java.rb:11:in `ensure_install!'
/usr/local/bundle/gems/sunspot_solr-2.6.0/lib/sunspot/solr/server.rb:27:in `initialize'
/usr/local/bundle/gems/sunspot_solr-2.6.0/lib/sunspot/solr/tasks.rb:38:in `new'
/usr/local/bundle/gems/sunspot_solr-2.6.0/lib/sunspot/solr/tasks.rb:38:in `server'
/usr/local/bundle/gems/sunspot_solr-2.6.0/lib/sunspot/solr/tasks.rb:10:in `block (3 levels) in <main>'
Tasks: TOP => sunspot:solr:start
(See full trace by running task with --trace)

当我运行

rake sunspot:solr:reindex

# rake sunspot:solr:reindex
rake aborted!
RSolr::Error::Http: RSolr::Error::Http - 400 Bad Request
Error: undefined field type

URI: http://solr:8983/solr/development/update?wt=json
Request Headers: {"Content-Type"=>"text/xml"}
Request Data: "<?xml version=\"1.0\" encoding=\"UTF-8\"?><delete><query>type:Album</query></delete>"
...

任何人都可以帮我添加哪些额外配置吗?

ruby-on-rails docker-compose solr
1个回答
0
投票

执行 Solar Start 命令时,错误消息清楚地表明 Java 未安装。

© www.soinside.com 2019 - 2024. All rights reserved.