What to do with missing fields in sunspot-rails?
Posted
by
chrismealy
on Stack Overflow
See other posts from Stack Overflow
or by chrismealy
Published on 2012-06-06T22:37:33Z
Indexed on
2012/06/06
22:40 UTC
Read the original article
Hit count: 198
I'm using sunspot/rails version 2. It's working great, but I can't figure out how to handle missing fields. If I don't have latitude and longitude this code will map it to 0,0 (near Africa):
searchable do
text :resume, :stored => true
text :city, :boost => 5
latlon(:geo) { Sunspot::Util::Coordinates.new(latitude, longitude) }
end
I tried using two search blocks, each with a different conditional, but sunspot just uses the first searchable block. What I want to happen is for things missing locations to still be searchable, just not by location.
© Stack Overflow or respective owner