My search form looks like this:
<%= form_tag tours_path, method: :get do %>
<%= text_field_tag :query, params[:query] %>
<%= select_tag "engine", options_for_select(["elastic", "sphinx"]) %>
<%= submit_tag "Search", name: nil, class: "btn btn-mini btn-success" %>
<br>
Name: <%= text_field_tag :name %><br>
Cost: from <%= text_field_tag :cost_from %> to <%= text_field_tag
:cost_to %><br>
Direction: <%= text_field_tag :direction %><br>
Country: <%= text_field_tag :country, %><br>
<% end %>
I want to be able to do an advanced search (basically just include Name,
Cost, Direction and Country to the search as filters)
tours_controller:
def index
if params[:engine] == "elastic"
@tours = Tour.tire.search(params[:query], load: true)
elsif params[:engine] == "sphinx"
@tours = Tour.search (params[:query])
else
@tours = Tour.all
end
end
I tried something like this: Tour.search
"#{params[:query]}#{params[:name]}", :match_mode => :all , but it didn't
work
/indices/tour_index.rb
ThinkingSphinx::Index.define :tour, :with => :active_record do
#fields
indexes summary
indexes country, direction, cost, sortable: true
indexes :name, sortable: true
# attributes
#has cost
end
Thanks.
--
You received this message because you are subscribed to the Google Groups
"Thinking Sphinx" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/thinking-sphinx.
For more options, visit https://groups.google.com/groups/opt_out.