The error has resurfaced. I think it's an indexing error, as oppose to
MYSQL problem. Can someone take a look to see if there's a better way to
setup my index?
Here's the index:
ThinkingSphinx::Index.define :location, :with => :active_record do
indexes city
has "RADIANS(locations.latitude)", :as => :latitude, :type => :float
has "RADIANS(locations.longitude)", :as => :longitude, :type => :float
end
ThinkingSphinx::Index.define :user, :with => :active_record, :delta => true
do
indexes name, :as => :user, :sortable => true
indexes letsgos.content
indexes religion, about_me, height, career, feet, inches, sexuality,
children, user_smoke, user_drink, politics, gender, ethnicity, education,
email, zip_code
has created_at, updated_at
has "RADIANS(locations.latitude)", :as => :latitude, :type => :float
has "RADIANS(locations.longitude)", :as => :longitude, :type => :float
has(:id, :as => :user_id)
has age
has username
has birthday
set_property :wordforms => 'lib/word.txt'
join location
end
I modified the index so that I can display random users on my homepage.
Searches Controller:
def index
if current_user.present?
@search = Search.new
if params["min_age"].present? and params[:search].present?
conditions = {}
range_cond = {}
conditions[:gender] = params["gender"].join('|') if
params["gender"].present?
conditions[:ethnicity] = params["ethnicity"].join('|') if
params["ethnicity"].present?
if params["zip_code"].present?
l = Location.find_by_zip_code(params["zip_code"])
lat = l.latitude * Math::PI / 180.0
lng = l.longitude * Math::PI / 180.0
else
lat = current_user.latitude * Math::PI / 180.0
lng = current_user.longitude * Math::PI / 180.0
end
conditions[:religion] = params["religion"].join('|') if
params["religion"].present?
range_cond[:age] = if params["min_age"].present? and
params["max_age"].present?
params["min_age"].to_i..params["max_age"].to_i
elsif params["min_age"].present?
params["min_age"].to_i..65
elsif params["max_age"].present?
18..params["max_age"].to_i
end
range_cond[:geodist] = 0.0..100_000.0
conditions[:children] = params["children"].join('|') if
params["children"].present?
@users = if params[:search].present?
User.search(params[:search], :conditions => conditions,
:with => range_cond,
:geo => [lat, lng],
:order => 'geodist ASC', :without => {:user_id => current_user.id}
)
else
User.search(:conditions => conditions,
:with => range_cond,
:geo => [lat, lng],
:order => 'geodist ASC', :without => {:user_id => current_user.id}
)
end
else
params[:search] = params[:search] || ''
@users = User.search(params[:search].gsub(/\s+/, ' | '),
:geo => [current_user.latitude * Math::PI / 180.0, current_user.longitude *
Math::PI / 180.0],
:with => {:geodist => 0.0..100_000.0},
:order => 'geodist ASC', :without => {:user_id => current_user.id})
end
render 'users/index', layout: 'new_application'
else
redirect_to "/signup"
end
--
You received this message because you are subscribed to the Google Groups
"Thinking Sphinx" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/thinking-sphinx.
For more options, visit https://groups.google.com/d/optout.