When to specify type in index definition

5 views
Skip to first unread message

Ngan

unread,
Mar 8, 2013, 7:08:22 PM3/8/13
to thinkin...@googlegroups.com
Hi, I'm a little bit unclear when I need to specify the "type" option in define_index?

e.g.

define_index do
  has foo(:cool), type: :boolean
end

Will TS just know that the column is boolean or integer? Or do I always need to specify.  Specifically, i'm joining another table/model's attribute.

Thanks!

Pat Allan

unread,
Mar 9, 2013, 9:22:25 AM3/9/13
to thinkin...@googlegroups.com
If your column pairs directly to a Sphinx type (integer, boolean, string, float, timestamp/datetime), then attributes of that column - whether it's through an association or not - will have that type.

Date, text and decimal columns are treated as timestamp, string and float types, respectively.

For anything else - or anything where you're opting for a SQL snippet, instead column and association references - you will need to specify a type manually.

And this all applies to attributes - as far as Sphinx is concerned, no matter the database type, fields are strings.

Hope this clears things up :)

--
Pat

> --
> You received this message because you are subscribed to the Google Groups "Thinking Sphinx" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to thinking-sphi...@googlegroups.com.
> To post to this group, send email to thinkin...@googlegroups.com.
> Visit this group at http://groups.google.com/group/thinking-sphinx?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>


Reply all
Reply to author
Forward
0 new messages