【发布时间】:2010-10-27 19:29:21
【问题描述】:
我正在使用 django 和 sphinx 构建搜索应用程序。我得到了设置,但是当我搜索时,我得到了不相关的结果。这就是我所做的 -
# 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 位。所有排名靠前的结果都是垃圾。我如何使用Django-sphinx 来order 或sort 我的结果。
相反,我可以做些什么来使用此设置使结果更相关。
注意:我使用的是 python 2.6.x + django 1.2.x + sphinx 0.99 + django-sphinx 2.3.3 + mysql
另外,我定制的数据只有大约 100 行,只有一个字段 name 可搜索。还有一个字段rating(就是您在括号中看到的)。 rating 字段是一个属性(不可搜索)。
【问题讨论】:
标签: python django search sphinx django-sphinx