Created
December 29, 2011 21:41
-
-
Save robdimarco/1536342 to your computer and use it in GitHub Desktop.
Simple Business class with a text and a location
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
class Business < ActiveRecord | |
searchable do | |
text :name # Will be stored as a field named name_text in Solr | |
text :location # Will be stored as a field named location_text in Solr | |
end | |
end | |
# Given data set | |
# ID Name Location | |
# 1 Boone Moving Service Raleigh, NC | |
# 2 Bone’s Moving New York, NY | |
# 3 Boone Moving Los Angeles, CA | |
# 4 Jimmy’s Movers Boone, NC | |
# | |
# this query will match records 1 & 3 | |
# | |
# > Sunspot.index!(Business.all) | |
# > search = Business.search{keywords "Boone Moving"} | |
# > puts search.results.map(&:id) | |
#[1,3] |
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
<!-- Pertinent schema.xml configuration --> | |
<fieldType name="text" class="solr.TextField" omitNorms="false"> | |
<analyzer> | |
<tokenizer class="solr.StandardTokenizerFactory"/> | |
<filter class="solr.StandardFilterFactory"/> | |
<filter class="solr.LowerCaseFilterFactory"/> | |
</analyzer> | |
</fieldType> | |
<!-- ... --> | |
<dynamicField name="*_text" stored="false" type="text" multiValued="true" indexed="true"/> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment