2

Hey. I use Rails 3.0.1 with thinking-sphinx.

How can I get a list of IDs from a sphinx request? If I do

MyModel.search('boby').map(&:id)

it makes a request to the database which is redundant.

xpepermint
  • 35,055
  • 30
  • 109
  • 163

1 Answers1

6

You can call search_for_idsmethod to return just the primary key values, instead of instances of ActiveRecord objects.

MyModel.search_for_ids 'body'
Chandra Patni
  • 17,347
  • 10
  • 55
  • 65