Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between Thinking Sphinx indexing methods

Wondering what is the difference between these:

indexes shop.created_at, :as =>created_at
has shop(:created_at), :as => :created_at
has shop.created_at, :as => :created_at

Thanks.

like image 852
Victor Avatar asked Mar 11 '26 00:03

Victor


1 Answers

So I dont think there is a difference between the 2nd and 3rd (correct me if I am wrong!) however, I am sure of the difference between the 1st and 2nd

indexes is used to specify a field - according to the Thinking Sphinx website:

Fields are the content for your search queries – so if you want words tied to a specific document, you better make sure they’re in a field in your index. They are only string data – you could have numbers and dates and such in your fields, but Sphinx will only treat them as strings, nothing else.

has is used to specify an attribute - again, according to the Thinking Sphinx website:

Attributes are used for sorting, filtering and grouping your search results. Their values do not get paid any attention by Sphinx for search terms, though, and they’re limited to the following data types: integers, floats, datetimes (as Unix timestamps – and thus integers anyway), booleans, and strings. Take note that string attributes are converted to ordinal integers, which is especially useful for sorting, but not much else.

like image 91
Omar Qureshi Avatar answered Mar 12 '26 16:03

Omar Qureshi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!