私のRailsアプリケーションでIndextankのオートコンプリート機能を使用するのに問題があります。私はsearchifyを使って自分のインデックスとタンカーの宝石をホストし、インデックス(https://github.com/kidpollo/tanker)を作成しています。私はここのガイド(http://www.searchify.com/documentation/tutorial-autocomplete)とここ(https://github.com/flaptor/indextank-jquery/)に従って動作させるが、結果は得られないバック。私は検索ダッシュボードでパブリックAPIを有効にしました。IndexTankのオートコンプリートがTanker gemのRails 3で動作しない
タンカー宝石がデータをインデックス化する方法(1つのインデックスで複数のモデルにインデックスを付けることができます)と問題があると思います。同じ問題がここに報告されました - 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
これは私がオートコンプリートをテストするために使用したコードです。また、私はクリスねえ、ここSearchifyから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 %>
ありがとうございました。私は、textという別のフィールドのインデックスを作成することで、その問題を解決できました。 – sjbamber
'field'パラメータを指定すると、オートコンプリート用の任意のフィールドを使用できます。 http://indexden.com/documentation/api#autocompleteを参照してください。 –