I've added config to previous gist:
http://gist.github.com/64335
The tables are like (listing only important columns):
restaurants:
id: integer
name: string
feature_options:
id: integer
name: string
feature_id: integer
radio: string
# restaurants and feature_options join table
restaurant_feature_options:
id: integer
feature_option_id: integer
restaurant_id: integer
# it's for grouping feature_options - feature_options belongs_to
features
features:
id: integer
name: string
The error says that pgsql can't find feature_options.restaurant_id
column (and it's correct as feature_options doesn't have one).
It seems that thinking sphinx omits finder_sql and just tries to get
feature_options as they were regular has_many with
feature_options.restaurant_id =
restaurants.id (in fact
choosen_radio_options are like has_many through).
I've tried to use 'has' with sql argument, but I can't figure out how
to insert JOINS and DISTINCT there. (DISTINCT is very important in
this query. it has to select the feature with most votes).
Are you sure that TS should use :finder_sql in config generation?
On Feb 15, 9:30 am, Pat Allan <
p...@freelancing-gods.com> wrote:
> Hi Piotr
>
> Ideally, your original approach - using chosen_radio_features(:id) -
> should do the trick, and it shouldn't generate errors. It will also
> add the sql_attr_multi definition to the configuration file.
>
> So, we should try to figure out why it isn't working, though. Can you
> put your original error-generating config onto gist?
>
> As a work-around, you can edit the config file manually, and then when
> you index, you'll need to set the INDEX_ONLY environment variable as
> well, to ensure the file isn't overwritten:
>
> rake ts:in INDEX_ONLY=true
>
> Of course, should you make changes to your config via ruby later,
> you're going to have to overwrite the file and re-apply your custom
> edit.
>
> Cheers
>
> --
> Pat
>
> On 15/02/2009, at 7:21 PM, Piotr Sarnacki wrote:
>
>
>
> > I had some time to play with it and probably the best way is to add
> > sql_attr_multi definition to config file. I've added ithttp://
gist.github.com/64643