pat / thinking-sphinx

Sphinx/Manticore plugin for ActiveRecord/Rails
http://freelancing-gods.com/thinking-sphinx
MIT License
1.63k stars 468 forks source link

Sphinx's internal attribute '@rank' doesn't work #320

Closed janko closed 12 years ago

janko commented 12 years ago

I have a normal

@songs = Song.search(params[:search], :page => params[:page], per_page => 10)

When I add :order => "@rank ASC", nothing changes. So, if I switch between DESC and ASC, it is supposed to give me results in reverse orders, but it always gives me in the same order. It works with one of my columns, or with other Sphinx's internal attributes (like @random), but @rank (@relevance, @weight) doesn't work.

Also, :rank_mode => :sph04 doesn't work. I'm sure I did everything right. I have "Lol Rofl Lmao" and "Lol Rofl", and when I type "lol rofl", I still get "Lol Rofl Lmao" first (because his ID is lower than "Lol Rofl"'s). I don't know if it's a Sphinx's thing, but I'm sure didn't make any mistakes.

An insteresting thing. I accidentally put :rank_mode => :phrase (I forgot to change :rank_mode to :match_mode), and it acted as if I had used :match_mode. When I typed "lol rofl lmao", it didn't find "Lol Rofl", only "Lol Rofl Lmao". Maybe this will help.

pat commented 12 years ago

What happens if you add in :match_mode => :extended?

On 19/12/2011, at 8:03 AM, Janko Marohnić wrote:

I have a normal

@songs = Song.search(params[:search], :page => params[:page], per_page => 10)

When I add :order => "@rank ASC", nothing changes. So, if I switch between DESC and ASC, it is supposed to give me results in reverse orders, but it always gives me in the same order. It works with one of my columns, or with other Sphinx's internal attributes (like @random), but @rank (@relevance, @weight) doesn't work.

Also, :rank_mode => :sph04 doesn't work. I'm sure I did everything right. I have "Lol Rofl Lmao" and "Lol Rofl", and when I type "lol rofl", I still get "Lol Rofl Lmao" first (because his ID is lower than "Lol Rofl"'s). I don't know if it's a Sphinx's thing, but I'm sure didn't make any mistakes.

An insteresting thing. I accidentally put :rank_mode => :phrase (I forgot to change :rank_mode to :match_mode), and it acted as if I had used :match_mode. When I typed "lol rofl lmao", it didn't find "Lol Rofl", only "Lol Rofl Lmao". Maybe this will help.


Reply to this email directly or view it on GitHub: https://github.com/freelancing-god/thinking-sphinx/issues/320

janko commented 12 years ago

Holy shit, now everything works. I didn't know I had to pass it. Thanks :)

I didn't quite understand from the documentation, when do I need to add it?

pat commented 12 years ago

That's not quite clear, yeah... I don't think Sphinx gets carried away with weighting scores for the other match modes - in the default (:all), everything that matches just gets a score of 1. So I don't think :rank_mode comes into the equation then. It certainly does for the extended match mode.

janko commented 12 years ago

Yeah, I noticed nothing changed when I used different rankers. I'll just add that option in these cases then. Thanks :)

nikhilgupte commented 12 years ago

This still doesn't work (even after specifying :match_mode as :extended and :extended2). The order (asc/desc) makes no difference for any value of rank_mode.

I've checked it on 1.4.12

pat commented 12 years ago

Hi Nikhil, can you run us through the queries you're running?