Hi Roger

Turns out this was indeed a bug - not sure if once upon a time ActiveRecord 
didn’t have a default scope covering subclasses for STI, but it certainly does 
now, which means Thinking Sphinx doesn’t need to (badly) do that.

No idea if this breaks on old versions of ActiveRecord, but I guess I’ll deal 
with that if/when someone raises it :)

Fix is in the develop branch:

  gem ‘thinking_sphinx’, ‘~> 3.1.2’,
    :git    => ‘git://github.com/pat/thinking-sphinx.git',
    :branch => ‘develop’,
    :ref    => ‘46e73dc9fb’

Cheers

— 
Pat

On 13 Nov 2014, at 2:37 am, Roger Kind Kristiansen 
<[email protected]> wrote:

> I'm experimenting with indexing on a model using STI here, where a bunch of 
> the subclasses will be searched in pretty much the same manner. Therefore I'm 
> trying to set up an index on a class which is not the base class, but which 
> is the parent of the aforementioned subclasses. It might be simpler to grok 
> with an example
> 
> class Person; end
> class SpecialistDoctor < Person
> class Gynecologist < SpecialistDoctor
> class Pediatrician < SpecialistDoctor
> ...
> 
> I'm trying to set up the index on the SpecialistDoctor. The problem is that 
> the index always turns out empty. I've defined a pretty minimal one after I 
> ran into some problems:
> 
> ThinkingSphinx::Index.define :specialist_doctor, with: :active_record do
>   indexes [firstname, lastname], as: :name
> end
> 
> This yields the following sql_query in specialist_doctor_core_0. I've 
> formatted it for readability and marked the culprit in red:
> 
> SELECT 
>     "people"."id" * 18 + 7 AS "id",
>     COALESCE(NULLIF("people"."type", ''), 'SpecialistDoctor') AS 
> "sphinx_internal_class_name",
>     COALESCE("people"."firstname", '') || ' ' || 
> COALESCE("people"."lastname", '') AS "name", 
>     "people"."id" AS "sphinx_internal_id", 
>     COALESCE(NULLIF("people"."type", ''), 'SpecialistDoctor') AS 
> "sphinx_internal_class", 
>     0 AS "sphinx_deleted"
> FROM "people"
> WHERE 
>     "people"."type" IN ('SpecialistDoctor', 'Gynecologist', 'Pediatrician')
>     AND ("people"."type" = 'SpecialistDoctor' AND "people"."id" BETWEEN 
> $start AND $end) 
> GROUP BY 
>     "people"."id", "people"."firstname", "people"."lastname", "people"."id", 
> "people"."type"
> 
> 
> I would greatly appreciate some input on whether what I'm trying to do is 
> simply not supported or if am I am just doing it wrong? I've tried this on 
> both v3.1.1 and v3.1.2.
> 
> Thanks,
> Roger
> 
> -- 
> 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 [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/thinking-sphinx.
> For more options, visit https://groups.google.com/d/optout.

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/thinking-sphinx.
For more options, visit https://groups.google.com/d/optout.

Reply via email to