簡體   English   中英

在開發Rails中使用Solr和Sunspot

[英]Using solr and sunspot in development Rails

我正在嘗試在Rails應用程序中配置黑子,但我希望它與已安裝的solr-tomcat一起使用,因為我正在使用無所事事來管理開發機器。

根據本教程的前兩個步驟,我已經使用apt-get安裝了solr-tomcat: https : //www.digitalocean.com/community/tutorials/how-to-install-solr-on-ubuntu-14-04

並且我已經將gem sunspot_rails添加到gemfile中,並且還成功運行了rails generate sunspot_rails:install並相應地配置了config / sunspot.xml

production:
  solr:
    hostname: localhost
    port: 8080
    log_level: WARNING
    path: /solr/production

development:
  solr:
    hostname: localhost
    port: 8080
    log_level: INFO
    pid_dir: '/var/run'
  disabled: false

test:
  solr:
    hostname: localhost
    port: 8081
    log_level: WARNING
    path: /solr/test

由於我使用的是無業游民,所以我希望它對於其他可能加入該項目的開發人員來說都是開箱即用的,這就是為什么我不安裝gem sunspot_solr

我有一種想念的東西,但我不知道為什么。

當我嘗試rake sunspot:solr:reindex它拋出HTTP Status 404 - /usr/share/solr/development/update - The requested resource is not available.

** Invoke sunspot:solr:reindex (first_time)
** Invoke sunspot:reindex (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute sunspot:reindex
Skipping progress bar: for progress reporting, add gem 'progress_bar' to your Gemfile
rake aborted!
RSolr::Error::Http: RSolr::Error::Http - 404 Not Found
Error: <html><head><title>Apache Tomcat/6.0.39 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 404 - /solr/default/update</h1><HR size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u>/solr/default/update</u></p><p><b>description</b> <u>The requested resource is not available.</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/6.0.39</h3></body></html>

Request Data: "<?xml version=\"1.0\" encoding=\"UTF-8\"?><delete><query>type:User</query></delete>"

注意:用戶是我應用程序中的模型

Solr正在運行,因為我可以毫無問題地訪問localhost:8080 / solr / admin

我已經手動安裝了solr,因為反正repo是過時的版本,請使用本教程https://www.digitalocean.com/community/tutorials/how-to-install-solr-on-ubuntu-14-04

然后將其添加到gemfile gem sunspot_solr ,進行捆綁並rake sunspot:solr:start gem sunspot_solr rake sunspot:solr:start以生成solr/conf/schema.xml ,我將其復制到opt/solr/solr/{APP_NAME}

並像這樣配置我的config/sunspot.yml

development:
  solr:
    hostname: localhost
    port: 8983
    log_level: INFO
    path: /solr/{APP_NAME}
    solr_home: solr
  disabled: false

並且工作正常!

有關我已保存的要點的完整注釋,請隨時使用;)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM