Hi Graham

The problem is that Thinking Sphinx doesn't limit queries for certain  
models to particular indexes. A workaround would be to add a zero  
integer attribute in your other models of the same name:
   has "0", :as => :x, :type => :integer

It's not great, but it should do the job.

Also, ideally you want attributes in :with, not :conditions (in recent  
versions of TS, using :conditions for attributes is considered  
deprecated).

-- 
Pat

On 07/08/2009, at 1:39 AM, Graham Glass wrote:

>
> Hi everyone,
>
> This is a follow-up from a previous question I had.
>
> I have 2 classes A and C with a common abstract base class B.
> A and C both have an attribute called "x" that's in their "a" and "b"
> database tables.
> I also have other classes D and E that don't have an attribute called
> "x".
>
> Here is "A":
>
> class A < B
>  set_table_name "a"
>
>  define_index do
>    indexes name
>    has x
>  end
> end
>
> Here is "C":
>
> class C < B
>  set_table_name "c"
>
>  define_index do
>    indexes name
>    has x
>  end
> end
>
> If I search like this, there is no problem:
>
> A.search 'name', :conditions => {:x => 5}
>
> But if I search like this, I get an error:
>
> ThinkingSphinx::Search.search 'name', :conditions => {:x => 5}
>
> The error message:
>
> matches = [[], {:fields=>[], :attribute_names=>[], :error=>"index
> a_core,c_core,d_core,e_core: query error: no field 'x' found in
> schema", :status=>1, :matches=>[], :attributes=>{}, :words=>{}}]
>
> I thought I could use the generic "search" method to search across all
> classes for anything with a matching attribute. Does anyone have an
> idea of what I'm doing wrong? I also tried:
>
> ThinkingSphinx::Search.search 'name', :conditions => {:x =>
> 5}, :classes => [A, C]
>
> to try and limit it to just the classes with the attribute 'x', but I
> got the same error message.
>
> Thanks in advance!
>
> Cheers,
> Graham
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Thinking Sphinx" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/thinking-sphinx?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to