pat / thinking-sphinx

Sphinx/Manticore plugin for ActiveRecord/Rails

Home Page:http://freelancing-gods.com/thinking-sphinx

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allow for using :uuid as primary_key

anthonyshull opened this issue · comments

There are a few places where it is assumed that applications are using the default :bigint primary_key and therefore have rt_attr_bigint = sphinx_internal_id. We are using :uuid. I have made some hacky changes to my fork to get it working with uuids. I can devote some time to make it work with the rest of the library. I'm thinking some kind of config variable. The default can use bigint but you can also set it to uuid. Thoughts?

@anthonyshull thanks for the suggestion! In the past I'd said this wasn't possible… but that was back when Sphinx didn't fully handle String attributes. And given you've gotten it working, it sounds like it is possible!

I guess the preferred behaviour I'd love is that TS figures out that the primary key isn't an integer/bigint automatically, and just switches to using a string attribute instead for sphinx_internal_id, rather than requiring a change at a config level. If you want to have a go at that, that'd be brilliant. If you get stuck though (I realise there's a lot going on in the TS code), I'm happy to have a look at your fork and see if we can figure out next steps together.

Ok, looks like I can get the primary key type from the model. I'll try to have a PR this week.