I'm having trouble getting Indextank's AutoComplete feature to work in my Rails application. I'm using searchify to host my index and the Tanker gem to create my index (https://github.com/kidpollo/tanker). I have followed the guide here (http://www.searchify.com/documentation/tutorial-autocomplete) and here (https://github.com/flaptor/indextank-jquery/) to get it working but I get no results back. I have enabled the public API in the searchify dashboard.
I think the problem is to do with the way the Tanker gem indexes the data (It can index multiple models in one index). The same issue was reported here - https://github.com/kidpollo/tanker/issues/25 - but i'm confused with the resolution that was given. I'm not sure what is meant by :indexes => :text in this instance. Can anyone shed a bit more light on what I need to do?
This is my model where I index data. No other model indexes data yet
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
This is the code I've used to test autocomplete. I have also tried using the example from 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 %>
Hey Chris here from Searchify. I'm too familiar with the Tanker gem yet. But Searchify/IndexTank by default searches in the document field called 'text', including for autocomplete suggestions. So try indexing your data (title, description, or post_comments, from your code snippet) in the 'text' field. If you still have problems, contact me via the website or our support email and I can look at your index to see how you (and tanker) are indexing things.