#PERSON MODEL
define_index do
indexes name
indexes tag_taggings.tag(:name), as: :tags
has :id
has view_count, as: :impressions
has "COUNT(comments.id)", as: :reviews, type: :integer
has "COUNT(DISTINCT votes.id)", as: :rating_count, type: :integer
has "SUM(CASE votes.vote WHEN TRUE THEN 1.0 ELSE -1.0 END)", as: :rating,
type: :float
has "RADIANS(lat)", as: :lat, type: :float
has "RADIANS(lng)", as: :lng, type: :float
has created_at, updated_at
group_by "lat", "lng"
join comments
join votes
end
#PERSON CONTROLLER
conditions = {}
%w(name tags).each do |i|
i = i.to_sym
next unless params[i]
conditions[i] = params[i]
end
#SORT RATINGS
if params[:o] == "rate_desc"
order_by = "rating DESC"
elsif params[:o] == "rate_asc"
order_by = "rating ASC"
elsif params[:o] == "rate_count_desc"
order_by = "rating_count DESC"
elsif params[:o] == "rate_count_asc"
order_by = "rating_count ASC"
#SORT REVIEWS
elsif params[:o] == "reviews_desc"
order_by = "reviews DESC"
elsif params[:o] == "reviews_asc"
order_by = "reviews ASC"
#SORT VIEWS
elsif params[:o] == "views_desc"
order_by = "impressions DESC"
elsif params[:o] == "views_asc"
order_by = "impressions ASC"
#SORT TIME
elsif params[:o] == "day"
filters = { :created_at => 1.day.ago..Time.now }
order_by = "created_at DESC"
elsif params[:o] == "week"
filters = { :created_at => 1.week.ago..Time.now }
order_by = "created_at DESC"
elsif params[:o] == "month"
filters = { :created_at => 1.month.ago..Time.now }
order_by = "created_at DESC"
elsif params[:o] == "year"
filters = { :created_at => 1.year.ago..Time.now }
order_by = "created_at DESC"
else
order_by = "created_at DESC"
end
#SEARCH IT!
p = Person.search(params[:q], :conditions => conditions, :order =>
order_by, :with => filters, :per_page => 9999999)
On Friday, December 7, 2012 5:32:59 AM UTC-5, Pat Allan wrote:
>
> Hi Mike
>
> Can you share with us your full index definition?
>
> Cheers
>
> --
> Pat
>
> On 07/12/2012, at 5:20 AM, Mike C. wrote:
>
> > Also, when I filter :order => "plusminus ASC"
> >
> > I added some down votes to 3 users. It did put those three users to the
> top of the results, the problem is that the order of those 3 results is
> wrong. It is showing up as the order I voted on them -1, -2, -2 (-1 being
> the last user I voted on)
> >
> > --
> > You received this message because you are subscribed to the Google
> Groups "Thinking Sphinx" group.
> > To view this discussion on the web visit
> https://groups.google.com/d/msg/thinking-sphinx/-/ZACphJWXKDIJ.
> > To post to this group, send email to
> > [email protected]<javascript:>
> .
> > To unsubscribe from this group, send email to
> [email protected] <javascript:>.
> > For more options, visit this group at
> http://groups.google.com/group/thinking-sphinx?hl=en.
>
>
>
--
You received this message because you are subscribed to the Google Groups
"Thinking Sphinx" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/thinking-sphinx/-/ESfL1edDbL4J.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/thinking-sphinx?hl=en.