kidpollo / tanker

IndexTank Integration with your fav ORM
MIT License
97 stars 30 forks source link

Certain keywords break the search_tank method #30

Closed ghost closed 13 years ago

ghost commented 13 years ago

I encountered another difficulty while using the gem. I'm using Rails 3 and still using 1.8.7 Ruby (some gems are not compatible with the newer version)

Anyway, I have this code in my view <%= form_tag search_path, :id => 'search_bar', :method => 'get' do %> <%= text_field_tag :search, params[:search], :id =>"header-search-textbox", :placeholder => 'Search your moments here' %> <%= submit_tag "Search", :id => 'header-search-btn', :name => nil %> and my controller: @moments = Moment.search_tank(params[:search], :variables => {0 => @group.id}) render 'some_page'

The problem is that my search function is broken for some keywords, for example: 'facebook', 'photo', or 'I'. Other random strings e.g. 'qwerty' or 'asdfg' actually ran and returned nil result and some other keywords return the expected results. However, for the few keywords mentioned above, instead of returning me nil result for my moments instance variable, it stops there and the page redirects to a 'page not found' route. It didn't run my render code.

Once again, I am really not sure how those few keywords break the search function. Some help here, anyone?

For now, I am using Indextank's client to get the query and there's no problem, just filing this report to check whether there's something that I'm missing...

joeljunstrom commented 13 years ago

What does tanker return when you get the error? ie. what's @moments.inspect at that point? Need some more info to help you mate, a stack trace etc

kidpollo commented 13 years ago

yes @ronnypm it does sound very odd, can you please elaborate?

ghost commented 13 years ago

It just occurred to me that there might be an uncaught exception. So here's the exception message:

Couldn't find all Moments with IDs (27, 3, 2, 1, 26, 25, 23, 24) (found 5 results, but was looking for 8)

This is what I've done: I searched the term 'facebook', and it's supposed to return 3 moments with that term for my particular user. With the exception handling, it returns me nil.

Then, I went to indextank app on heroku, and tried this query 'title:facebook", and it returns me 8 results.

I am working on this project with a friend, and both of us are using the same index with our own local database, perhaps indextank is confused because there are some IDs which does not exist on my database?

arvida commented 13 years ago

Yep, it looks like you are having documents in your indextank index that doesn't exists in your local database. It would probably be a good idea to have your own seperate indexes when developing =) IndexTank offer a free "Starter" plan that you could use for local development.

I guess this is a bit related to issue #32, would nice for these kinds of errors to not break your app in production =)