pat / thinking-sphinx

Sphinx/Manticore plugin for ActiveRecord/Rails
http://freelancing-gods.com/thinking-sphinx
MIT License
1.63k stars 468 forks source link

Allow for using :uuid as primary_key #1209

Open anthonyshull opened 2 years ago

anthonyshull commented 2 years ago

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?

pat commented 2 years ago

@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.

anthonyshull commented 2 years ago

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