Rails 2-> 3からアップグレードするプロジェクトに参加しています。Ultrasphinx(Rails 3ではサポートされていません)を削除し、ThinkingSphinxに置き換えます。1つの問題-ThinkingSphinxがテストモードでファイルのインデックスを作成していないため、以前は機能していた検索用のCucumberテストが失敗します。
これは、env.rbの関連部分です。
require 'cucumber/thinking_sphinx/external_world'
Cucumber::ThinkingSphinx::ExternalWorld.new
Cucumber::Rails::World.use_transactional_fixtures = false
そして、これが私のオブジェクトにインデックスを付けるステップ(私のcommon_steps.rbファイルで宣言されている)です:
Given /^ThinkingSphinx is indexed$/ do
puts "Indexing the new database objects"
# Update all indexes
ThinkingSphinx::Test.index
sleep(0.25) # Wait for Sphinx to catch up
end
そして、これは私が.featureファイルに持っているものです(モデルオブジェクトが作成された後)
And ThinkingSphinx is indexed
これは、テストモードで実行したときのThinkingSphinxの出力です(これは間違っています。ドキュメントを検索する必要がありますが、そうではありません)
Sphinx 0.9.9-release (r2117)
Copyright (c) 2001-2009, Andrew Aksyonoff
using config file 'C:/Users/PaulG/Programming/Projects/TechTV/config/test.sphinx.conf'...
indexing index 'collection_core'...
collected 0 docs, 0.0 MB
total 0 docs, 0 bytes
total 0.027 sec, 0 bytes/sec, 0.00 docs/sec
distributed index 'collection' can not be directly indexed; skipping.
indexing index 'video_core'...
collected 0 docs, 0.0 MB
total 0 docs, 0 bytes
total 0.018 sec, 0 bytes/sec, 0.00 docs/sec
distributed index 'video' can not be directly indexed; skipping.
total 0 reads, 0.000 sec, 0.0 kb/call avg, 0.0 msec/call avg
total 8 writes, 0.000 sec, 0.1 kb/call avg, 0.0 msec/call avg
rotating indices: succesfully sent SIGHUP to searchd (pid=4332).
比較すると、これは私が実行したときに得られる出力です
rake ts:index
開発環境にインデックスを付けるには:
Sphinx 0.9.9-release (r2117)
Copyright (c) 2001-2009, Andrew Aksyonoff
using config file 'C:/Users/PaulG/Programming/Projects/TechTV/config/development.sphinx.conf'...
indexing index 'collection_core'...
collected 4 docs, 0.0 MB
sorted 0.0 Mhits, 100.0% done
total 4 docs, 39 bytes
total 0.031 sec, 1238 bytes/sec, 127.04 docs/sec
distributed index 'collection' can not be directly indexed; skipping.
indexing index 'video_core'...
collected 4 docs, 0.0 MB
sorted 0.0 Mhits, 100.0% done
total 4 docs, 62 bytes
total 0.023 sec, 2614 bytes/sec, 168.66 docs/sec
distributed index 'video' can not be directly indexed; skipping.
total 10 reads, 0.000 sec, 0.0 kb/call avg, 0.0 msec/call avg
total 20 writes, 0.001 sec, 0.1 kb/call avg, 0.0 msec/call avg
rotating indices: succesfully sent SIGHUP to searchd (pid=5476).
テストデータベースではなく、開発データベースで実際にドキュメントを検索していることに注目してください。インデクサーは開発で機能していますが、テストではありませんか?私はこれに2日間を費やしましたが、解決策に近づくことはできません。どんな助けでも圧倒的にありがたいです。