2012-04-09 12 views
1

私の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 %> 

答えて

0

からの例を使用して試してみました。私はまだタンカーの宝石に精通しています。しかし、Searchify/IndexTankは、デフォルトでは、テキストフィールド内で「テキスト」を検索し、オートコンプリート候補も含めて検索します。だから、あなたのデータ(タイトル、説明、またはあなたのコードスニペットのpost_comments)を 'text'フィールドにインデックスを作成してみてください。それでも問題が解決しない場合は、ウェブサイトまたはサポートメールで私に連絡し、あなたのインデックスを見て、あなたとタンカーがどのようにインデックスを作成しているかを調べることができます。

+0

ありがとうございました。私は、textという別のフィールドのインデックスを作成することで、その問題を解決できました。 – sjbamber

+0

'field'パラメータを指定すると、オートコンプリート用の任意のフィールドを使用できます。 http://indexden.com/documentation/api#autocompleteを参照してください。 –

関連する問題