Pat,
I was able to get some logging code installed on the staging server
where we're experiencing this problem. In a nutshell, if the same
search is repeated a second time after it's run and doesn't return any
results the second run seems to almost always return results.
Here is sample output from the .results method when searching the user
model and getting nothing (there should be 17 matches):
2010-07-19 05:35:42 INFO
>>> User:
{:time=>0.0, :status=>0, :words=>{},
:attribute_names=>["sphinx_internal_id", "class_crc", "subclass_crcs",
"sphinx_deleted", "user_id", "specialty_ids", "geographic_focus_ids",
"product_type_ids", "target_market_ids", "created_at", "updated_at",
"activated_at"],
:fields=>["email", "first_name", "last_name", "biography", "company",
"title", "location", "specialty_name", "geographic_name",
"target_market_name", "product_type_name"],
:attributes=>{"geographic_focus_ids"=>1073741825, "activated_at"=>2,
"created_at"=>2, "specialty_ids"=>1073741825, "updated_at"=>2,
"sphinx_deleted"=>1, "user_id"=>1, "subclass_crcs"=>1073741825,
"target_market_ids"=>1073741825, "product_type_ids"=>1073741825,
"class_crc"=>1, "sphinx_internal_id"=>1},
:matches=>[], :total_found=>0, :total=>0}
And here's the same search a moment later, returning 17 results:
2010-07-19 05:38:29 INFO
>>> User:
{:time=>0.0, :status=>0, :words=>{},
:attribute_names=>["sphinx_internal_id", "class_crc", "subclass_crcs",
"sphinx_deleted", "user_id", "specialty_ids", "geographic_focus_ids",
"product_type_ids", "target_market_ids", "created_at", "updated_at",
"activated_at"],
:fields=>["email", "first_name", "last_name", "biography", "company",
"title", "location", "specialty_name", "geographic_name",
"target_market_name", "product_type_name"],
:attributes=>{"geographic_focus_ids"=>1073741825, "activated_at"=>2,
"created_at"=>2, "specialty_ids"=>1073741825, "updated_at"=>2,
"sphinx_deleted"=>1, "user_id"=>1, "subclass_crcs"=>1073741825,
"target_market_ids"=>1073741825, "product_type_ids"=>1073741825,
"class_crc"=>1, "sphinx_internal_id"=>1},
:matches=>[{:doc=>203, :weight=>1, :attributes=>{"geographic_focus_ids"=>[2,
3], "activated_at"=>1279257375, "created_at"=>1279257336,
"specialty_ids"=>[1, 40], "updated_at"=>1279353426,
"sphinx_deleted"=>0, "user_id"=>40, "subclass_crcs"=>[765557111],
"target_market_ids"=>[1, 2, 3], "product_type_ids"=>[1, 2, 3],
"class_crc"=>765557111, "sphinx_internal_id"=>40}, :index=>0},
{:doc=>198, :weight=>1, :attributes=>{"geographic_focus_ids"=>[2, 9],
"activated_at"=>1279256766, "created_at"=>1279256738,
"specialty_ids"=>[1, 2, 12, 14], "updated_at"=>1279256776,
"sphinx_deleted"=>0, "user_id"=>39, "subclass_crcs"=>[765557111],
"target_market_ids"=>[1], "product_type_ids"=>[4, 5],
"class_crc"=>765557111, "sphinx_internal_id"=>39}, :index=>1},
{:doc=>193, :weight=>1, :attributes=>{"geographic_focus_ids"=>[2, 9],
"activated_at"=>1279238381, "created_at"=>1279238360,
"specialty_ids"=>[1], "updated_at"=>1279238401, "sphinx_deleted"=>0,
"user_id"=>38, "subclass_crcs"=>[765557111], "target_market_ids"=>[1],
"product_type_ids"=>[4], "class_crc"=>765557111,
"sphinx_internal_id"=>38}, :index=>2},
{:doc=>183, :weight=>1, :attributes=>{"geographic_focus_ids"=>[2, 9],
"activated_at"=>1278668949, "created_at"=>1278668941,
"specialty_ids"=>[1, 2, 12, 14], "updated_at"=>1279238030,
"sphinx_deleted"=>0, "user_id"=>36, "subclass_crcs"=>[765557111],
"target_market_ids"=>[1, 2], "product_type_ids"=>[1, 3],
"class_crc"=>765557111, "sphinx_internal_id"=>36}, :index=>3},
{:doc=>173, :weight=>1, :attributes=>{"geographic_focus_ids"=>[2, 4,
8, 11, 13], "activated_at"=>1278550287, "created_at"=>1278550261,
"specialty_ids"=>[1, 2, 3, 4, 12, 13, 15, 17, 18, 25, 28, 36],
"updated_at"=>1278550373, "sphinx_deleted"=>0, "user_id"=>34,
"subclass_crcs"=>[765557111], "target_market_ids"=>[1, 2, 3, 4, 5],
"product_type_ids"=>[1, 4, 5, 6, 9], "class_crc"=>765557111,
"sphinx_internal_id"=>34}, :index=>4},
{:doc=>158, :weight=>1, :attributes=>{"geographic_focus_ids"=>[2],
"activated_at"=>1276169658, "created_at"=>1276169635,
"specialty_ids"=>[1], "updated_at"=>1276169663, "sphinx_deleted"=>0,
"user_id"=>31, "subclass_crcs"=>[765557111], "target_market_ids"=>[1,
2, 3, 4, 5], "product_type_ids"=>[1], "class_crc"=>765557111,
"sphinx_internal_id"=>31}, :index=>5},
{:doc=>138, :weight=>1, :attributes=>{"geographic_focus_ids"=>[2],
"activated_at"=>1275343055, "created_at"=>1275343040,
"specialty_ids"=>[1], "updated_at"=>1279265282, "sphinx_deleted"=>0,
"user_id"=>27, "subclass_crcs"=>[765557111], "target_market_ids"=>[1,
2, 3, 4, 5], "product_type_ids"=>[3], "class_crc"=>765557111,
"sphinx_internal_id"=>27}, :index=>6},
{:doc=>113, :weight=>1, :attributes=>{"geographic_focus_ids"=>[0],
"activated_at"=>1275028713, "created_at"=>1275028670,
"specialty_ids"=>[1], "updated_at"=>1275028793, "sphinx_deleted"=>0,
"user_id"=>22, "subclass_crcs"=>[765557111], "target_market_ids"=>[0],
"product_type_ids"=>[0], "class_crc"=>765557111,
"sphinx_internal_id"=>22}, :index=>7},
{:doc=>103, :weight=>1, :attributes=>{"geographic_focus_ids"=>[5],
"activated_at"=>1274861509, "created_at"=>1274861487,
"specialty_ids"=>[1, 3], "updated_at"=>1279237832,
"sphinx_deleted"=>0, "user_id"=>20, "subclass_crcs"=>[765557111],
"target_market_ids"=>[5], "product_type_ids"=>[4],
"class_crc"=>765557111, "sphinx_internal_id"=>20}, :index=>8},
{:doc=>88, :weight=>1, :attributes=>{"geographic_focus_ids"=>[2, 8],
"activated_at"=>1272584976, "created_at"=>1272584956,
"specialty_ids"=>[1, 2, 5], "updated_at"=>1272585002,
"sphinx_deleted"=>0, "user_id"=>17, "subclass_crcs"=>[765557111],
"target_market_ids"=>[3, 4, 5], "product_type_ids"=>[1, 2, 11],
"class_crc"=>765557111, "sphinx_internal_id"=>17}, :index=>9}],
:total_found=>17, :total=>17}
One thing I noticed is that the :status value is 0 for both the failed
and successful search. From looking at the other log entries it seems
like :status => 0 means results were found. Can you enlighten me on
what :status means?
Again, thanks for taking a look at this for me. Let me know if you
have any other suggestions.
On Jul 11, 6:25 am, Pat Allan <[email protected]> wrote:
> Hi Chris
>
> .results is a hash, and the most relevant key is :matches, which is an array
> of hashes containing the information about the matching documents. So that's
> the first thing to check (ie: if that's empty, then it's not a TS bug). There
> may also be warnings/errors - I'm not sure if that'll appear in .results, but
> it *should* appear in the logs, so that's another good place to look.
>
> Cheers
>
> --
> Pat
>
> On 11/07/2010, at 3:23 PM, Chris McCann wrote:
>
> > Pat,
>
> > I've added the .results output to the logging I'm doing but I'm not
> > sure what I should be looking for. If you were trying to solve this
> > problem what would you hope to see in that output that would point out
> > potential issues?
>
> > Thanks,
>
> > Chris
>
> > On Jul 9, 8:41 am, Pat Allan <[email protected]> wrote:
> >> Hi Chris
>
> >> Unfortunately, I've never seen this problem before... it's certainly an
> >> odd one. I know it's probably hard to reproduce, but if you can log what
> >> the value of Model.search(args).results is, that'd be fantastic - as
> >> that's the raw Sphinx results (as a bundle of hashes and arrays), and
> >> should confirm whether the problem is happening in TS or Sphinx - though
> >> I'm pretty certain it's the latter.
>
> >> It's probably worth searching/asking on the Sphinx forums as
> >> well:http://sphinxsearch.com/forum/forum.html?id=1
>
> >> Good luck!
>
> >> --
> >> Pat
>
> >> On 09/07/2010, at 4:48 PM, Chris McCann wrote:
>
> >>> We're having an issue in a Rails 2.3.5 app with thinking_sphinx 1.3.16
> >>> in terms of inconsistent search results for the same inputs to TS.
> >>> We're using MySQL 5.1.41.
>
> >>> I've checked the parameters passed into the model's .search() method
> >>> on every call. With identical inputs the correct results are usually
> >>> returned, but on occasion some of the expected results will be
> >>> missing. This is on a development database that only I am hitting, so
> >>> there's nothing happening to the underlying data between these search
> >>> calls.
>
> >>> The development log also shows that sphinx is returning different
> >>> results from the same inputs (my debug statements prefaced with >>>):
>
> >>>>>> search_options => {:page=>1, :per_page=>10, :sort_mode=>:desc,
> >>>>>> :order=>"created_at", :with=>{:specialty_ids=>[29], :location_ids=>[6,
> >>>>>> 2, 3, 4, 5]}}
>
> >>> Sphinx Querying: ''
> >>> Sphinx (0.002381s) Found 4 results
>
> >>>>>> search_options => {:page=>1, :per_page=>10, :sort_mode=>:desc,
> >>>>>> :order=>"created_at", :with=>{:specialty_ids=>[29], :location_ids=>[6,
> >>>>>> 2, 3, 4, 5]}}
>
> >>> Sphinx Querying: ''
> >>> Sphinx (0.002279s) Found 0 results
>
> >>> We are using the :retry_stale => true setting as well.
>
> >>> I'm at a loss for how to spelunk into the thinking_sphinx code to sort
> >>> out what's going wrong. If anyone has seen this behavior I'd love to
> >>> hear what you did to fix or investigate it. If not, any suggestions
> >>> for a way forward to sort this out would be much appreciated.
>
> >>> Cheers,
>
> >>> Chris
>
> >>> --
> >>> 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
> >>> athttp://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
> > athttp://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.