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 基于IDs的Ruby太阳黑子关键字搜索_Ruby On Rails_Ruby_Search_Solr_Sunspot - Fatal编程技术网

Ruby on rails 基于IDs的Ruby太阳黑子关键字搜索

Ruby on rails 基于IDs的Ruby太阳黑子关键字搜索,ruby-on-rails,ruby,search,solr,sunspot,Ruby On Rails,Ruby,Search,Solr,Sunspot,简单问题: 我有两种型号:Show和Contact。我想做的是搜索Show#id或Contact#name。因此,我的模型设置如下: class Show < ActiveRecord::Base searchable do text :id end end class Contact < ActiveRecord::Base searchable do text :name end end 这对于按姓名查找联系人非常有效,但对Show#id

简单问题:

我有两种型号:
Show
Contact
。我想做的是搜索
Show#id
Contact#name
。因此,我的模型设置如下:

class Show < ActiveRecord::Base

  searchable do
    text :id
  end
end

class Contact < ActiveRecord::Base

  searchable do
    text :name
  end
 end
这对于按姓名查找联系人非常有效,但对
Show#id
字段不起作用。有人能解释为什么会这样吗


Joe

id字段是一个整数,因此模型中应该有
integer:id
。您需要指定正确的数据库列类型。查看位于的示例。

是的,但是我不能做我想做的事情,即在关键字搜索中包含该模型的id。
Sunspot.search(Contact, Show) do
  keywords(MY_QUERY)
end