Skip to content

Instantly share code, notes, and snippets.

@shanna
Created January 5, 2009 04:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shanna/43267 to your computer and use it in GitHub Desktop.
Save shanna/43267 to your computer and use it in GitHub Desktop.
DataMapper.setup(:default, options = {}) # Your :default repo.
DataMapper.setup(:search, :adapter => 'sphinx')
class Item
include DataMapper::Resource
# .. normal properties and such for :default
# This property is a computed field that only exists in :search aka your sphinx index{}.
# They do not have to exist in :default.
repository(:search) do
property :my_extra_field, String
end
end
# Search using extra field:
repository(:search) { Item.all(:my_extra_field => 'chicken') }
# Or if you are using dm-is-searchable:
Item.search(:my_extra_field => 'chicken')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment