Created
January 5, 2009 04:59
-
-
Save shanna/43267 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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