Reputation: 21
I've setup sunspot and I'm searching fine in my Place.name
field
Now I want to search by "acts as taggable" tags
I've setup two contexts to taggable, categories
with this model and controller I'm not getting any errors but when I search for my tag name sunspot doesn't return any results.
I've run rake sunspot:reindex
and rake sunspot:solr:reindex
but no change.
When I run Place.last.categories
in rails console I only get one array ["Category one","Category 2"]
Model
class Place < ActiveRecord::Base
extend FriendlyId
friendly_id :name, use: :slugged
searchable :auto_index => true, :auto_remove => true do
text :name, :stored => true
string :category_list, :multiple => true, :stored => true
end
acts_as_votable
acts_as_mappable :default_units => :kms,
:lat_column_name => :latitude,
:lng_column_name => :longitude
validates_presence_of :name , :state, :city, :neighborhood, :adress,:latitude, :longitude
belongs_to :user
acts_as_ordered_taggable_on :categories, :obstacles
end
Controller
class PlacesController < ApplicationController
before_action :set_place, only: [:show, :edit, :update, :destroy, :upvote, :downvote, :favorite]
before_action :authenticate_user!, except: [:index, :show]
# GET /places
# GET /places.json
def index
@search = Place.search do
fulltext params[:search]
end
@places = @search.results
end
Upvotes: 1
Views: 85