Hi Walter

The :include option is sent through to ActiveRecord when loading the search 
results, so you should be able to use that - add this to your search query:
  :include => :contents

-- 
Pat

On 14/09/2012, at 3:29 PM, Walter Lee Davis wrote:

> I am continuing on my full-text search journey, and trying to speed up the 
> process of building excerpts. Using a great suggestion from Pat Allan, I now 
> have my excerpts showing up correctly. But now my SQL looks like this (and my 
> results display in modem-time):
> 
> Started GET "/search/results?page=13&q=orange" for 66.92.229.108 at 
> 2012-09-14 07:25:02 -0700
>  Processing by SearchController#results as HTML
>  Parameters: {"page"=>"13", "q"=>"orange"}
>  SQL (1.1ms)  SHOW TABLES
>  SQL (0.7ms)  SHOW TABLES
>  SQL (10.7ms)  SHOW TABLES
>  SQL (0.7ms)  SHOW TABLES
>  SQL (0.9ms)  SHOW TABLES
>  SQL (0.8ms)  SHOW TABLES
>  SQL (1.1ms)  SHOW TABLES
>  SQL (1.1ms)  SHOW TABLES
>  Sphinx Query (3.1ms)  orange
>  Sphinx  Found 324 results
>  Title Load (4.7ms)  SELECT `titles`.* FROM `titles` WHERE `titles`.`id` IN 
> (274, 235, 2044, 101, 94, 2052, 1786, 2062, 1751, 757, 1726, 2081, 1714, 273, 
> 1696, 1695, 711, 268, 1693, 1692)
>  Content Load (51.3ms)  SELECT `contents`.* FROM `contents` WHERE 
> (`contents`.title_id = 274)
>  Content Load (77.8ms)  SELECT `contents`.* FROM `contents` WHERE 
> (`contents`.title_id = 235)
>  Content Load (11.6ms)  SELECT `contents`.* FROM `contents` WHERE 
> (`contents`.title_id = 2044)
>  Content Load (71.9ms)  SELECT `contents`.* FROM `contents` WHERE 
> (`contents`.title_id = 101)
>  Content Load (35.4ms)  SELECT `contents`.* FROM `contents` WHERE 
> (`contents`.title_id = 94)
>  Content Load (18.1ms)  SELECT `contents`.* FROM `contents` WHERE 
> (`contents`.title_id = 2052)
>  Content Load (26.1ms)  SELECT `contents`.* FROM `contents` WHERE 
> (`contents`.title_id = 1786)
>  Content Load (24.8ms)  SELECT `contents`.* FROM `contents` WHERE 
> (`contents`.title_id = 2062)
>  Content Load (11.5ms)  SELECT `contents`.* FROM `contents` WHERE 
> (`contents`.title_id = 1751)
>  Content Load (16.9ms)  SELECT `contents`.* FROM `contents` WHERE 
> (`contents`.title_id = 757)
>  Content Load (33.0ms)  SELECT `contents`.* FROM `contents` WHERE 
> (`contents`.title_id = 1726)
>  Content Load (43.4ms)  SELECT `contents`.* FROM `contents` WHERE 
> (`contents`.title_id = 2081)
>  Content Load (37.0ms)  SELECT `contents`.* FROM `contents` WHERE 
> (`contents`.title_id = 1714)
>  Content Load (24.3ms)  SELECT `contents`.* FROM `contents` WHERE 
> (`contents`.title_id = 273)
>  Content Load (7.6ms)  SELECT `contents`.* FROM `contents` WHERE 
> (`contents`.title_id = 1696)
>  Content Load (14.2ms)  SELECT `contents`.* FROM `contents` WHERE 
> (`contents`.title_id = 1695)
>  Content Load (41.2ms)  SELECT `contents`.* FROM `contents` WHERE 
> (`contents`.title_id = 711)
>  Content Load (9.0ms)  SELECT `contents`.* FROM `contents` WHERE 
> (`contents`.title_id = 268)
>  Content Load (13.7ms)  SELECT `contents`.* FROM `contents` WHERE 
> (`contents`.title_id = 1693)
>  Content Load (12.1ms)  SELECT `contents`.* FROM `contents` WHERE 
> (`contents`.title_id = 1692)
>  User Load (1.2ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 
> LIMIT 1
> Rendered search/results.html.erb within layouts/application (3088.4ms)
> 
> When I have excerpts off, naturally I don't load that content twice, I'm just 
> looking in the Sphinx data store for matches and returning titles (which are 
> lightweight metadata-only records). I'm not sure if this can be optimized any 
> further using an optimistic load, but if it can, how would I signal that in a 
> general (site-wide) search clause? I'm using this method in my 
> search_controller:
> 
>    @results = ThinkingSphinx.search params[:q], :page => params[:page], 
> :match_mode => :extended, :order => 'class_crc DESC, @relevance DESC'
> 
> Thanks again,
> 
> Walter
> 
> -- 
> 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.
> 

 

-- 
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