> 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.
It's not being logged in development.log. I'm on Rails 2.3.2. Perhaps I've mis-configured something? > 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). searchd.query.log show things like: [Tue Jul 21 01:29:47.312 2009] 0.001 sec [ext/2/rel 112 (0,1000000)] [*] @plan_status sub_grant_agreement_approved which is somewhat helpful, but I'm looking for the full SQL query. > All that aside, I suspect your problem is you're getting confused with > fields and attributes. Quite possible. > You are splitting your conditions into 2 hashes - > one used with :conditions, the other used for :with. The :with hash is for non-string fields, in this case booleans. With the :conditions hash, I'm using Sphinx’s extended match mode to constrain the results to certain values in string-based fields. I originally was using an attribute: has status, :as => :plan_status and eventually realized I can't use :with on string-based fields since TS calls #to_f on the value. That brought me to use the :conditions option, but I couldn't get correct results. Based on your responses, I finally realized I had to change my index definition to use :conditions, to wit: indexes status, :as => :plan_status And now it works! > In general :with should be used to specify attribute values only, And for non-string fields, yes? > and > :conditions can be used to specify field or attribute values. :conditions can be used to specify field values if you’re searching with a specific model (not multi-model searching). (from: http://rdoc.info/rdoc/freelancing-god/thinking-sphinx/blob/04320b610b3a665ca1885cc2e6f29354d029e49a/ThinkingSphinx/Search.html#search-class_method) In this case I am, so that would work, too. I hadn't realized that. Thx. Thanks again for putting me on the right path, /g -- George Anderson BenevolentCode LLC [email protected] > 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 -~----------~----~----~----~------~----~------~--~---
