If you want the SQL used when searching should be printed to your
development.log just after the "Sphinx: " entry. Sphinx only returns
numeric IDs and then rails does the SQL.
If you want the SQL sphinx uses to extract data from your DB when
indexing, it is listed in the Sphinx config file
(config/development.sphinx.conf).
The attribute values(those defined with has..) you're filtering with are
not logged anywhere.
All that aside, I suspect your problem is you're getting confused with
fields and attributes. You are splitting your conditions into 2 hashes -
one used with :conditions, the other used for :with.
In general :with should be used to specify attribute values only, and
:conditions can be used to specify field or attribute values. When in
doubt, just put all your conditions into the :conditions option.
Also, when you're filtering by attribute I'm pretty sure you can only
use exact matches or ranges.
-- James Healy <jimmy-at-deefa-dot-com> Tue, 21 Jul 2009 14:55:12 +1000
george.anderson wrote:
>
> MODEL:
> define_index do
> set_property :group_concat_max_len => 16384
>
> where "viewable = 1 AND model_year = '#{ CURRENT_MODEL_YEAR }'"
>
> has status, :as => :plan_status
> has school.address.state, :as => :state
> has partner.field_office.area_office(:id), :as => :region_id
> has tennessee_initiative_required
> has proposition49_required
> has physical_activity_and_nutrition_required
> has early_childhood_development_required
> has in_school_physical_activity_program_required
> has sponsorship_required
> has afterschool_literacy_program_required
> has in_school_literacy_program_required
> has summer_literacy_program_required
>
> indexes school.address.county, :as => :county
> indexes school.address.zip, :as => :zip
> indexes school.district, :as => :district
> indexes [program_specialist_nupa.last_name,
> program_specialist_nupa.first_name], :as => :program_specialist_nupa
> indexes [program_specialist_esss.last_name,
> program_specialist_esss.first_name], :as => :program_specialist_esss
> indexes partner.name, :as => :name
> end
>
>
> CONTROLLER:
> with_attributes = {}
> params[:program_components] && params[:program_components].each do
> |attribute|
> with_attributes[attribute.to_sym] = true
> end
>
> conditions = {}
> conditions[:plan_status] = params[:plan_status] unless params
> [:plan_status].blank?
>
> @plan_ids = Plan.search_for_ids( (params[:search] || ""),
> :with => with_attributes,
> :conditions => conditions,
> :per_page => 1_000_000 )
>
>
> For now I'm just 'logger.debug'ing the search code, like this:
>
> logger.debug "\n\nPlan.search_for_ids(('#{(params[:search] ||
> "")}'), :with => #{with_attributes.inspect}, :condtions => #
> {conditions.inspect})\n\n"
>
> Then I run it through script/console, which gets me part of the way.
>
> I'd really like to see the SQL statement that's generated, however.
> Is there any way to see that? (I'm on OSX.)
>
> Thanks for your help,
>
> /g
>
> --
>
> George Anderson
>
> BenevolentCode LLC
> [email protected]
>
> On Jul 19, 1:32 am, James Healy <[email protected]> wrote:
> > george.anderson wrote:
> > > I'm trying to see the generated SQL, but development.log isn't showing
> > > the query Thinking Sphinx is sending to Sphinx.
> >
> > <snip>
> >
> > > Should the query be listed after "Sphinx:"? Have I mis-configured
> > > something?
> >
> > In development.log you only see the search string used for fields.
> > Attribute values are not shown.
> >
> > Since all you get is "Sphinx:", presumably you're only filtering by
> > attributes.
> >
> > Can you provide a copy of your define_index block and the search syntax
> > you're using?
> >
> > -- James Healy <jimmy-at-deefa-dot-com> Sun, 19 Jul 2009 15:29:25 +1000
> >
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---