我有 4 个表来执行索引。我的问题是,
I want to get search results not by weight but by tables priority. I mean table 1 matched results show first then for table 2 and so on.
Currently, it is retrieving results by highest weight first.
查询
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;
最佳答案
如果仍然使用原来的SphinxAPI,有一个SetIndexWeights。 http://sphinxsearch.com/docs/current.html#api-func-setindexweights 尽管必须将数据拆分为单独的实际索引。
...SphinxQL 中没有类似的东西。据我所知
向索引添加新属性可能是最简单的
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;
关于php - 如何设置表的优先级?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47793661/