我在使用我的Rails应用程序时遇到了一些问题,那就是让Indextank的AutoComplete特性正常工作。我使用searchify来托管我的索引,使用Tanker gem来创建我的索引(https://github.com/kidpollo/tanker)。我已经按照指南在这里(http://www.searchify.com/documentation/tutorial-autocomplete)和这里(https://github.com/flaptor/indextank-jquery/)让它工作了,但我没有得到任何结果。我已经在searchify仪表板中启用了公共API。
我认为问题在于Tanker gem索引数据的方式(它可以在一个索引中索引多个模型)。这里报告了同样的问题- https://github.com/kidpollo/tanker/issues/25 -但我对给出的解决方案感到困惑。我不确定在这个实例中:indexes:=>是什么意思。有没有人能更详细地说明我需要做些什么?
这是我索引数据的模型。目前还没有其他模型对数据进行索引
class Post < ActiveRecord::Base
include Tanker
# Relationships
belongs_to :user
has_many :comments
tankit index do
indexes :title
indexes :description
indexes :post_comments do
comments.map {|comment| comment.description }
end
end
# define the callbacks to update or delete the index upon saving and deleting records
after_save :update_tank_indexes
after_destroy :delete_tank_indexes
end这是我用来测试自动补全的代码。我还尝试使用https://github.com/flaptor/indextank-jquery/中的示例
<script src='https://raw.github.com/flaptor/indextank-jquery/master/jquery.indextank.ize.js' type='text/javascript'></script>
<script src='https://raw.github.com/flaptor/indextank-jquery/master/jquery.indextank.autocomplete.js' type='text/javascript'></script>
<script type='text/javascript'>
var publicApiUrl = "myPublicURL";
var indexName = "myIndexName";
</script>
<script type='text/javascript'>
$(document).ready(function(){
// let the form be 'indextank-aware'
$("#myform").indextank_Ize(publicApiUrl, indexName);
// let the query box have autocomplete
$("#query").indextank_Autocomplete();
});
</script>
<%= form_tag 'posts/search', :method => :get, :id => 'myForm' do %>
<%= text_field_tag :query, "", :id => 'query' %>
<button type="submit">Search</button>
<% end %>发布于 2012-04-10 15:34:40
嗨,克里斯,我是Searchify的。我对油轮宝石太熟悉了。但默认情况下,Searchify/IndexTank会在名为“text”的文档字段中进行搜索,包括自动完成建议。因此,尝试在“post_comments”字段中索引您的数据(标题、描述或文本,来自您的代码片段)。如果您仍然有问题,请通过网站或我们的支持电子邮件与我联系,我可以查看您的索引,以了解您(和tanker)如何对事物进行索引。
https://stackoverflow.com/questions/10078323
复制相似问题