我正在使用django構建搜索應用程序& sphinx。我得到了設置工作,但是當我搜索時,我得到不相關的結果。這是我做的 -在Django中搜索應用程序
# this is in my trial_data Model
search = SphinxSearch(
index = 'trial_data trial_datastemmed',
weights = {'name': 100,},
mode = 'SPH_MATCH_ALL',
rankmode = 'SPH_RANK_BM25',
)
當我搜索我得到這個(從我的試驗數據) -
from trial.models import *
res = trial_data.search.query('godfather')
for i in res: print i
3 Godfathers (7.000000) Bonanno: A Godfather's Story (1999) (6.400000) Disco Godfather (4.300000) Godfather (6.100000) Godfather: The Legend Continues (0.000000) Herschell Gordon Lewis: The Godfather of Gore (2010) (6.900000) Mafia: Farewell to the Godfather (0.000000) Mumbai Godfather (2.600000) Russian Godfathers (2005) (7.000000) Stan Tracey: The Godfather of British Jazz (2003) (6.200000) The Black Godfather (3.500000) The Burglar's Godfather (0.000000) The Fairy Godfather (0.000000) The Fairy Godfather (0.000000) The Godfather (9.200000) The Godfather (1991) (6.400000)
的問題是「教父最相關的結果「顯示在第19位。所有最重要的結果都是垃圾。我如何才能order
或sort
我的結果使用Django-sphinx
。
相反,我可以做些什麼來使結果更加相關。
注:我使用python的2.6.x + Django的1.2.x版本+獅身人面像0.99 + Django的獅身人面像2.3.3 + MySQL的
而且,我定製&的數據只有100行與只有一個字段name
可搜索。還有一個字段rating
(這是你在括號中看到的)。 rating
字段是一個屬性(不可搜索)。
'.order_by('@ weight')'在這裏沒有效果,因爲我只用一個字段'name'進行搜索。如果您從多個字段搜索,則「@ weight」是有意義的。所以回來了,我已經試過了。它對'result_set'沒有影響。 – 2010-10-27 19:59:08
@movieyoda我編輯了我的答案,根據http://www.davidcramer.net/code/79/in-depth-django-sphinx-tutorial.html將「@weight」更改爲「@relevance」。 – 2010-10-27 20:03:32