I have a problem with sunspot. When i do a SOLR request i have always the same query.
SOLR Request (3.7ms) [ path=select parameters={fq: ["type:Tag"], start: 0, rows: 30, q: "*:*"} ]
No matter what I type in the search field , it's always the same query
Here my code :
tag.rb
class Tag < ActiveRecord::Base
belongs_to :pictogram
searchable do
text :name
end
end
searchs_controller.rb
class SearchsController < ApplicationController
def index
if params[:search]
pictograms = Array.new
@term = params[:query]
search = Tag.search do
fulltext @term
end
index = 0
search.results.each do |t|
if !pictograms.include? t.pictogram
pictograms[index] = t.pictogram
index = index + 1
end
end
@results = pictograms.group_by { |p| p.category }
@search_mode = true
end
end
end
index.html
<%= form_tag result_search_path do %>
<div class="input-group input-group-lg">
<%= search_field_tag :term,"#{@term}", class: 'form-control' %>
<span class="input-group-btn">
<%= submit_tag "Search", :class => 'btn btn-primary btn' %>
</span>
</div>
<% end %>
I think the params you are using for search are not correct.
means that the params that you are passing back to the controller is [:term],
so the code should be something like:
and not params[:search] and params[:query] like you have tried.