我有4个表来执行索引。我的问题是,
我希望搜索结果不是按重量而是按表优先级。一世 平均表1匹配的结果先显示表2,依此类推。
目前,它首先按最高权重检索结果。
查询
Select UUID_SHORT() AS sphinxid, info as keyword, 'column_name' as type from table 1
UNION ALL
Select UUID_SHORT() AS sphinxid, info as keyword, 'column_name' as type from table 2
UNION ALL
Select UUID_SHORT() AS sphinxid, info as keyword, 'column_name' as type from table 3
UNION ALL
Select UUID_SHORT() AS sphinxid, info as keyword, 'column_name' as type from table 4;
答案 0 :(得分:0)
如果仍然使用原始的SphinxAPI,那么就有一个SetIndexWeights。 http://sphinxsearch.com/docs/current.html#api-func-setindexweights 虽然必须将数据拆分为单独的实际索引。
...... SphinxQL中没有这样的等价物。 AFAIK
向索引添加新属性可能最简单
sql_query = \
Select ...,8 as multiplier from table1 \
UNION ALL \
Select ...,4 as multiplier from table2 \
UNION ALL \
...
sql_attr_uint = multiplier
然后在运行查询时,可以使用该因子
sphinxQL> SELECT id,WEIGHT()*multiplier AS w FROM index WHERE MATCH(..) ORDER BY w DESC;