我需要帮助让自动完成功能在我的 Solr 搜索栏上工作。我,使用这个https://github.com/xponrails/sunspot_autocomplete
按照步骤操作,它不起作用。
我卡在我的搜索栏上-如何将其添加到其中,同时保留参数 [:search]
其他人也有同样的问题,但删除了他们的代码,使其正常工作。
*它是否纯粹与 jquery-ui 自动完成有关?或者是否必须以某种方式安装插件 - 我不确定我是否正确安装了它。
谢谢你=)
我需要帮助让自动完成功能在我的 Solr 搜索栏上工作。我,使用这个https://github.com/xponrails/sunspot_autocomplete
按照步骤操作,它不起作用。
我卡在我的搜索栏上-如何将其添加到其中,同时保留参数 [:search]
其他人也有同样的问题,但删除了他们的代码,使其正常工作。
*它是否纯粹与 jquery-ui 自动完成有关?或者是否必须以某种方式安装插件 - 我不确定我是否正确安装了它。
谢谢你=)
请找到自动完成的步骤。我将举一个自动完成项目的例子。
第 1 步:创建一个自动完成文本字段,例如 <%= text_field_with_auto_complete 'item', 'name' %>
第 2 步:然后调用名为 auto_complete_for_item_name 的方法。
setp 3:在该方法中,从表中获取所有行并将其保存在名为@items 的变量中。
第 4 步:然后使用此 @items 变量调用新方法。像渲染 :inline => "<%= auto_complete_result @items, 'name','med_item'%>"
第 5 步:在那个方法中放入这样的 content_tag("ul", items.uniq.join)
它将根据输入的密钥列出所有项目。
如果我错了请纠正我..
感谢和问候,
维吉·库马尔
i just tried it for my project and it worked fine with this steps
sunspot
gems were included and installed (https://github.com/sunspot/sunspot/blob/master/README.md)gem 'sunspot_autocomplete', ">= 0.0.3", :git => 'git://github.com/xponrails/sunspot_autocomplete.git'
than proposed in manual)schema.xml
was modified (all necessary nodes were added inside blocks
<schema name="sunspot" version="1.0">
<types> *here* </types>
</fields> *and here* <fields>
</schema>
)searchable do; ...; end
block for the model were included (it has to be text field and autocompelte field with unique name addressed to text field with :using=>:[text field name]
syntax)searchable block
changesautocomplete_text_field
was added to view (i had to .html_safe
it because it was rendered as raw text)and it worked!
but i guess in one or more of this steps you missed something
if the all question is how to add the search field to template - you just need to add this row
<%= autocomplete_text_field("uniq", "field", "http://localhost:8982/solr/", "uniq_field") %>
- assuming you have indexed autocomplete :uniq_field, :using => :field
and pointed it to the live version of solr (http://localhost:8982/solr/
)
if you share with me some code i can point you to something you missed
cheers!