I just started to use Searchkick with my Rails web service, for the moment I just testing. I want retrieve users around a certain perimeter of a location with that.
For my Test I have a User object (with email, name...), and a Position object (with longitude, latitude and a reference to one User). And User have a has_many relation with Position.
for the moment my Position look like
class Position < ActiveRecord::Base
belongs_to :User
searchkick locations: ["location"]
def search_data
attributes.merge location: [latitude, longitude]
end
end
And I try to do a research like
Position.search *, where: {location: {near: [50.632049, 3.068322], within: "100mi"}}
But I get the following error
nested: QueryParsingException[[positions_development_20140310223244065] failed to find geo_point field [location]]; }]","status":400}
I don't know exactly what I have to do. (I'm new to rails, and elastic search) So if someone can give me a better explanation, I take it ! Thank's
Be sure to reindex after making changes to the searchkick or search_data methods.
Position.reindex
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With