Incidental nil's in result

3 views
Skip to first unread message

Menno van der Sman

unread,
Sep 17, 2008, 10:00:55 AM9/17/08
to Thinking Sphinx
Hi there,

I've applied a tiny patch to our ThinkingSphinx setup to fix a small
issue. When a sphinx-result could not be found in the database, a nil-
value would be included in the results. Simply compacting the result
fixes this:

Index: lib/thinking_sphinx/collection.rb
===================================================================
--- lib/thinking_sphinx/collection.rb (revision 1960)
+++ lib/thinking_sphinx/collection.rb (working copy)
@@ -43,7 +43,7 @@
) : []
ids.collect { |obj_id|
instances.detect { |obj| obj.id == obj_id }
- }
+ }.compact
end

def self.instance_from_match(match, options)

Hope this helps anybody,

Cheers,

Menno van der Sman




Pat Allan

unread,
Sep 18, 2008, 2:32:28 AM9/18/08
to thinkin...@googlegroups.com
Hi Menno

Ideally there shouldn't be any nil results... Thinking Sphinx should
flag deleted records as such in the indexes, and they shouldn't get
returned in search calls. Are you using delta indexes on your models?
I should set up some specs to test for this...

That said, patch is appreciated :)

Cheers

--
Pat

Menno van der Sman

unread,
Sep 18, 2008, 4:40:00 AM9/18/08
to Thinking Sphinx
Hi Pat,

Hmm, weird. I'm not using delta indexes btw. I tried to reproduce the
case on development and production and it seems that the index does
get properly updated.

Maybe this one time the update didn't get through?

I'll keep an eye out for when it happens again though. Thanks for the
support anyway.

Cheers,

Menno
Reply all
Reply to author
Forward
0 new messages