Thinking-Sphinx :with => @geodist returns no results

Posted by dansketcher on January 01, 2010
gems, Rails, rant, software development / No Comments

Having just recently started using Thinking Sphinx, I’ve been toying with the geograhical search that it provides to simply do distance-based searches while querying other information. The Geo-searching part of the manual shows how to do searches limiting distance:

# Searching for places within 10km
Place.search "pancakes", :geo => [@lat, @lng],
  :with => {"@geodist" => 0..10_000}
# Searching for places sorted by closest first
Place.search "pancakes", :geo => [@lat, @lng],
  :order => "@geodist ASC, @relevance DESC"

Unfortunately, the first style of query where @geodist is limited in range – when used as-is – does not work I found in my testing that I could order by @geodist as per the second query but when I added the :with range, I had no results.

The solution was actually simple, but really annoying. You have to use Floats instead of Integers for the range numbers! So changing the first query to:

Place.search "pancakes", :geo => [@lat, @lng],
  :with => {"@geodist" => 0.0..10_000.0}

# or more neatly

Place.search "pancakes", :geo => [@lat, @lng],
  :with => {"@geodist" => Range.new(0.0, 10_000.0)}

makes it all work. Now to get someone to update those docs!
Update: Updated!

On comments

Posted by dansketcher on April 15, 2009
rant / No Comments

Blog comments. I used to like them. Some of my blog posts even have threads of helpful and useful feedback left by you, dear reader. Or should I say, some of you.

More recently I have started receiving a new sort of comment. The specious or outright false, hit-and-run attacks from anonymous morons who have somehow decided that the access to a keyboard and a place to exercise it allows them to write whatever they want. Well not here.

Should have listened to Alex Payne earlier…

If you want to reply to me, trackbacks are still enabled (for now)…

New Job, more code, lots of ‘life’ things

Posted by dansketcher on November 16, 2006
rant, software development / No Comments

So it turns out that sometimes when someone calls a job a Project Managment role, they actually mean Sales. The interview is no help, because it’s all agreement and “we want to go that way” stuff. But you walk in the door and it’s something else.

Not fun.

So anyway, I’ve got another job.

And I’m married now. It’s been a busy coupla months!

The good thing is that I am away from phone calls long enough now to actually do some coding, and it”s a nice change. (truth be told, in the final days at the old place I was debugging Mambo just for something different.

On the plus side, I met some nice people at the old place, namely the PPQ girls and boys. If you’re not in Queensland, you’ve got no chance of knowing who they are, and if you are and you want a personalised plate, they’re who you have NO CHOICE but to use ;) But they’re tops.

Anyway, wine in hand, Ruby on Rails open in Editplus, and I’m home.


gem, rake, webricks hangs – resolved! (damn you windows)

Posted by dansketcher on September 03, 2006
Rails, rant, software development / 2 Comments

You know you’re in for a fun day when you go to the code that you were working on yesterday and it stops working today.

In this case, I tried to start webrick to check my site, and the damn thing would not start. It would get as far as “=> Booting WEBrick…” and then hang. Ok, fine. Google a bit, maybe it’s the firewall? stop the firewall, no good.

Then, I tried to upgrade rails. ‘gem install’ hangs, before it says “upgrading source index”. Hrm. Must be something wrong with ruby. Try “gem list -r” which does not work on this machine but does work on my other workstation. Ok, got to be a ruby problem – upgrade ruby. no good. upgrade again. no good.

Then I uninstalled, rebooted, and reinstalled. “gem install” works! hooray! I install all the dependencies I need, and try to start webrick. Same bloody issue.

At this point, it’s fairly clear that it’s not a ruby or rails issue, it’s got to be a windows issue. I google for (out of desperation) “webrick hang” and I see, 4 down, a blog entry called WEBrick Server Hangs in Windows XP – have a look and it recommends running the following command to flush the Winsock Catalogue:

netsh winsock reset

And everything is fixed. Rake runs, webrick runs, gems still work. Bye bye 3 hours of my life. Thanks Windows. You’re a champ.

Friggin Mambo

Posted by dansketcher on July 02, 2006
rant, software development / No Comments

I know Mambo has been pretty popular in the past. Personally I never warmed to it, because once I got past the fancy veneer it was excruciatingly difficult for a newbie to discover how to write a >1 page module.

Apparently, I am not alone in that difficulty. For the last week I’ve been trying to get a bit of Mambo work done at my new job and it seems that Mambo developers are so scarce that anyone who is worth their salt has a job in it while no-one else knows diddly about it.

Personally I’d be happier if I could get the sites redeveloped in ANYTHING, but that’s a bit hard when the customer actually likes the admin side of Mambo and sees no reason to change. Can’t blame them for that, really…

Anyway, what a PITA. Thanks to my buddy over at albinoirishman.org though, things might come good. But why is this ‘big thing’ from a year ago now nothing but a blip on the radar? I guess from the standpoint of a CMS-only website there are new frameworks out there like Drupal, but ferchrissakes, you’d think people would want to cash in those skills for which they worked so hard. Although, from what I’ve seen, it’s not worth the pain.

I love a good rant

Posted by dansketcher on June 19, 2006
rant / No Comments

I love to rant. Love it. Unfortunately, when I’m in the mood for a-ranting, I’m seldom calm enough to properly construct a sufficiently soul-destroying bile-fest to inflict upon my foes. That’s one of the reasons I wanted a blog. Another reason is to pay kudos to others, especially other champion ranters. There is also the banging on about crap that is the raison d’ĂȘtre of blogging in general – I’m good at that too.

One of my rant heroes is Zed Shaw. He cracks ’em out, disregarding any potential offence – the way it should be. The first rant of his I ever saw was an article entitled Indirection Is Not Abstraction, where he says (referring to EJB):

“To summarize, just to get to where we could add an object to the collection, we had to follow this chain of calls: new InitialContext() -> InitialContext.lookup() -> LocalSubscriptionHome.findByPrimaryKey() -> CustomerBean.addSubscription() -> CustomerBean.getSubscriptions() -> Collection.add(). An unbelievable 6 levels of indirection just to add a fucking object to a fucking collection. This is the kind of bullshit that chaps my ass purple and makes me want to eat babies.”

(emphasis his. That is pretty crap too, btw.)

I love it. He says it like he means it, and it hurts. Comedy gold. So I’ve made a “rant” post category, through which to vent bile. I hope it’s as much fun as it looks.