I am using Sunspot for search and my queries aren't returning any results. I am using an API to do the search.
Here is some relevant code:
class App < ActiveRecord::Base
searchable do
text :name, :boost => 5
text :description
end
end
Controller:
module Api
module V1
class AppsController < ApiBaseController
respond_to :json
class App < ::App
end
def index
@search = App.search do
fulltext params[:search]
end
@apps = @search.results
respond_with @apps
end
end
end
end
The URL I normally use to access the index method in the AppsController without searching is http://0.0.0.0:3000/api/apps
When trying to search, I use http://0.0.0.0:3000/api/apps?search=test
Is my search URL correct or should it be something like http://0.0.0.0:3000/api/apps?name=test
I've tried many different URL formats and they all return an empty result even though there is data in my db. I have also reindexed many times and it shows that 6 items were indexed, which is correct. Any ideas as to what is going on?
EDIT: it works fine when searching from the web app without using the api. It just returns empty when calling from the API url
i would try to remove the ::App
subclassing in your controller. my guess is it messes up sunspots or activerecords inference mechanisms regarding the table <-> class naming conventions.