karmi/tire — Issue #140: Geo Filter Support
Author: tcocca
Created: 2011-10-29 19:15:12+00:00
State: open

@karmi I want to open this ticket to start discussing the options of Geo Filtering support,

geo_bbox
geo_distance
geo_distance_range
geo_polygon

I wouldn't mind trying to stab at the geo support for the gem, just want to discuss what the DSL should look like,

Looks like the geo_ options are only available as filters and not part of the query. Have you thought about what that filter DSL would look like at all?

I'm thinking maybe something like the following:

````
filter :geo_bounding_box, :location, :top_left => [40.73, -74.1], :bottom_right => [40.717, -73.99]
filter :geo_distance, :distance => "200km", :location => [40.73, -74.1]
filter :geo_distance_range, :from => "20km", :to => "200km", :location => [40.73, -74.1]
filter :geo_polygon, :location, :points => [[40.73, -74.1],[40.73, -75.1], [41.73, -75.1], [41.73, -74.1]]
````

We would have to do some work in the #initialize method of the Tire::Search::Filter class to recognize these geo filters based on the type of filter, because they need to accept more arguments than the standard "terms" filter.

Or should we turn filter more into something like the Facet class that accepts a block and inside that block we could do a number of different things? maybe something like:

````
filter do
geo_bounding_box :location, :top_left => [40.73, -74.1], :bottom_right => [40.717, -73.99]
end

filter do
geo_distance :distance => "200km", :location => [40.73, -74.1]
end

filter do
geo_distance_range :from => "20km", :to => "200km", :location => [40.73, -74.1]
end

filter do
geo_polygon :location, :points => [[40.73, -74.1],[40.73, -75.1], [41.73, -75.1], [41.73, -74.1]]
end
````

Any thoughts on this?

Wondering what the best option to go with is. I'd love to hear thoughts on the dsl.

~ Tom