As everyone is aware in your searchable model you can define an index of type :text as well as :string, for example:
class Post < ActiveRecord::Base
searchable do
string :title
text :title, :body
end
I tried searching for the basic differences between a text field type and string field type and was able to get a basic understanding like:
So what i am looking for here is all the CONCEPTUAL as well as USAGE differences between a text field type and string field type so that i can weigh my opinions while defining a field as string or text or both.
Note: I am not saying that you provide all the differences in a single answer, one difference per answer will also do and but please make sure the difference you are giving is not given already.
Text Fields
When text fields are indexed, they are broken up into their constituent words and then processed using a definable set of filters (with Sunspot’s default Solr installation, they’re just lower-cased). This process is known as tokenization, and it’s what allow text fields to be searched using fulltext matching. You can read more about tokenization and the available filter options on the Solr wiki http://wiki.apache.org/solr/AnalyzersTokenizersTokenFilters.
String Fields
String fields store string data. How is this different from text fields? A text field is tokenized, which is to say it’s broken up into its constituent words; that’s how fulltext search works. String fields, on the other hand, are just indexed as-is: the indexed data is exactly that string, from beginning to end.
Docs
https://github.com/sunspot/sunspot/wiki/Setting-up-classes-for-search-and-indexing
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With