Skip to content

Commit

Permalink
Added ability to have thinking sphinx return all search result attrib…
Browse files Browse the repository at this point in the history
…utes instead of fetching the active record model
  • Loading branch information
Andrew Hunter authored and pat committed Mar 17, 2012
1 parent 5679e2b commit 5d4d0fb
Show file tree
Hide file tree
Showing 2 changed files with 272 additions and 248 deletions.
12 changes: 12 additions & 0 deletions lib/thinking_sphinx/search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,8 @@ def populate
def compose_results
if options[:ids_only]
compose_ids_results
elsif options[:attributes_only]
compose_attributes_results
elsif options[:only]
compose_only_results
else
Expand All @@ -444,6 +446,16 @@ def compose_ids_results
}
end

def compose_attributes_results
replace @results[:matches].collect { |match|
attributes = {}
match[:attributes].each do |name, value|
attributes[name.to_sym] = match[:attributes][name]
end
attributes
}
end

def compose_only_results
replace @results[:matches].collect { |match|
case only = options[:only]
Expand Down
Loading

0 comments on commit 5d4d0fb

Please sign in to comment.