Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/63.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 为什么我的索引丢失了斯芬克斯思考的文档?_Ruby On Rails_Sphinx_Thinking Sphinx - Fatal编程技术网

Ruby on rails 为什么我的索引丢失了斯芬克斯思考的文档?

Ruby on rails 为什么我的索引丢失了斯芬克斯思考的文档?,ruby-on-rails,sphinx,thinking-sphinx,Ruby On Rails,Sphinx,Thinking Sphinx,我在我的账户模型上定义了一个简单的斯芬克斯指数: define_index do indexes display_name indexes email_addresses.email_address has created_at set_property :delta => :datetime, :threshold => 2.minutes end (暂时忽略增量;我正在生成完整索引并搜索account\u core) 但我得到了一些意想不到的结果: >&

我在我的
账户
模型上定义了一个简单的斯芬克斯指数:

define_index do
  indexes display_name
  indexes email_addresses.email_address

  has created_at
  set_property :delta => :datetime, :threshold => 2.minutes
end
(暂时忽略增量;我正在生成完整索引并搜索
account\u core

但我得到了一些意想不到的结果:

>> Account.count
# => 885138

>> Account.search.total_entries
# => 260795

>> Account.search("lenny@paperlesspost.com")
# => []
但是,在命令行上,使用
搜索
实用程序,我可以找到Lenny:

$ search -c /etc/sphinx/water.sphinx.conf -i account_core drew@example.com

index 'account_core': query 'drew@example.com.com ': returned 2 matches of 2 total in 0.759 sec

displaying matches:
1. document=3543432, weight=4, sphinx_internal_id=442101, sphinx_deleted=0, class_crc=0, created_at=Mon Apr 11 12:18:08 2011
2. document=5752816, weight=2, sphinx_internal_id=719552, sphinx_deleted=0, class_crc=0, created_at=Tue Dec 27 12:01:12 2011
事实上,这些都是德鲁的账户ID


为什么我用斯芬克斯思考搜索时找不到莱尼?为什么
total\u条目
的数量比
accounts
表中的行总数要小得多?

事实证明,问题与思考Sphinx如何处理单表继承有关。TS仅返回具有与父类的子类之一相对应的
类型的记录。如果
type
NULL
,则该文档不包括在搜索结果中。我们在
accounts
表中有很多记录
type=NULL
。修复数据后,搜索现在可以按预期工作

感谢roman3x in#sphinxsearch为我指出这一点