Picky with geocoder in rails

44 views
Skip to first unread message

Kingsley Hendrickse

unread,
Oct 17, 2013, 7:34:00 AM10/17/13
to picky...@googlegroups.com
Firstly thanks for writing Picky it looks pretty awesome. I have a question about integrating picky into an application I'm building.

I have rails application with a Venue model:

Venue
:name
:description
:address
:latitude
:longitude

I want to let users search for venues by name and also by proximity to a starting postcode. So a user may search for venues within 10 miles of a postcode and that does a partial match on the name.

Using the geocoder gem I'm able to search by proximity with Venue.near('name',range_in_miles) which solves my problem. But how could I use Picky and Geocoder together? Is there a recommended way?

In the near future a venue will have several sub categories - like 'non-smoking', 'countryside' etc and I would like to include these in the search. Plus there will be a Suppliers model which will list services nearby.

any pointers would be great

Picky / Florian Hanke

unread,
Oct 17, 2013, 8:12:13 AM10/17/13
to picky...@googlegroups.com
Hi Kingsley,

Thanks for reposting it on the mailing list :)

A good start are probably these two posts on my blog:

Let me try to answer your questions in turn.

Putting Picky and Geocoder together is probably not trivial as one uses data from the database and the other uses a special index. Another idea would be to quickly try Picky alone.
But if you want to combine them somehow, I can see two ways:
- Naïve: Search in Picky, and search via geocoder, then combine (by intersecting the result ids) the results.
- More involved: Make Geocoder a piece of Picky, and include it in there.

Then, the other idea would be to just use Picky. Since it's relatively easy to do, a good idea might be to quickly put together a Picky script to try it. Something like:

venues = Index::Memory.new :venues do
  source { Venue.all }
  category :name, partial: Partial::Substring.new(from: 1) 
  geo_categories :latitude, :longitude, 1.61, precision: 3
end

That's how the index would look like.

It's probably a good idea to watch the videos in the blog posts first and try your hand at it, and come back if you need answers :)

The subcategories you describe are available in Picky. And as long as you can associate suppliers with a venue when indexing, you could also make a venue searchable through suppliers (I hope I understand correctly).

Cheers,
   Florian
Reply all
Reply to author
Forward
0 new messages