php - 如何设置表的优先级?

标签 php mysql sphinx

我有 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/

相关文章:

php - 使用 PHPExcel 时未找到类 'ZipArchive' 错误

linux - APC每次100%碎片

javascript - 如何根据数据库中的下拉选择更改文本框值

android - 如何在android项目中加载VS2010生成的自己的.dll库?

php - 使用 Sphinx 过滤多对多 int 值

php - 如何用 php 显示 sphinx 搜索结果?

php - 如何在日期 ('H:i:s' 中添加 +3 )?

php - Laravel 5 获取 View 名称

php - 如何在jquery中传递数据库id

php - 当表名存储在变量中时,如何加载数据?