Rubytastic
Rubytastic

Reputation: 15501

sunspot solr: search for "Everything" / wildcard

How would one search in Sunspot solr with a wildcard? Use * does not work, I want to return all the results for education.

Education is a collection that can exists of "All", "High", "Low", so now my idea is to remove it from the search block if its "All"

with(:orientation, params[:orientation])  
if params[:orientation].present? unless params[:orientation] == "all"

Must be a better way?

Search block:

search = Sunspot.search Session do

      if params[:education].present?
        if params[:education] == "all"
          # Use a wildcard here
          #with(:education, *)
        end
      end
end

Upvotes: 0

Views: 399

Answers (2)

Rubytastic
Rubytastic

Reputation: 15501

solution:

I finally found the problem, I had some issues in my development database where Profile was not having a Match. + some missing profile_id in the match table, after fixing those the reindex went fine.

Upvotes: 0

Maurizio In denmark
Maurizio In denmark

Reputation: 4284

The best way is actually to remove the query as you say. It's cleaner and is quicker because the engine has one less condition to run. So:

with(:orientation, params[:orientation])  
if params[:orientation].present? unless params[:orientation] == "all"

is indeed the best solution.

Upvotes: 1

Related Questions