ruby - Rails 4 : Issue when searching using Sunspot and Solr -
i set sunspot , solr give rails app powerful search functionnality.
the install process straight-forward , did basic stuff required :
add gems
gem 'sunspot_rails' gem 'sunspot_solr' gem 'progress_bar'
run commands
bundle rails generate sunspot_rails:install bundle exec rake sunspot:solr:start rake sunspot:solr:run rake sunspot:solr:reindex
everything fine on level , documents created correctly.
now search, doesn't work well. here did on model , controller :
domain.rb
class domain < activerecord::base searchable text :name, stored: true end end
homecontroller.rb
class homecontroller < applicationcontroller def index @domains = domain.search fulltext params[:q], fields: [:name], highlight: true paginate page: params[:page], per_page: 12 end end end
my actual datas list of domain names (e,g, google.com, facebook.com...etc...)
- when searching
goo
, returns nothing. - when searching
google.com
, findsgoogle.com
.
i realized surrounding fulltext
argument *
produce similar select * domains name '%:name%'
does.
@domains = domain.search fulltext "*#{params[:q]}*", fields: [:name], highlight: true paginate page: params[:page], per_page: 12 end
however, not work if search multiple words great pizza
(hoping find great-super-giant-pizza.com
example).
i might have miss point on sunspot/solr setup.
any idea?
edit
to clarify bit case, tried simple search such :
domain.search { fulltext 'great pizza' }
as shown in example. not work. sunspot/solr trying find text matching great pizza
instead of finding text match 2 words
Comments
Post a Comment