Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
mysql按关联顺序匹配_Mysql_Sql_Match - Fatal编程技术网

mysql按关联顺序匹配

mysql按关联顺序匹配,mysql,sql,match,Mysql,Sql,Match,我试图根据相关性和顺序对结果进行排序 SELECT d.s_title, oc_t_item.*, oc_t_item.s_contact_name as s_user_name, MATCH (d.s_title) AGAINST ('"myvi xt"') AS exact_phrase, MATCH (d.s_title) AGAINST ('+myvi +xt"') AS both_keyword FROM (oc_t_item) LEFT JOIN oc_t_item_desc

我试图根据相关性和顺序对结果进行排序

SELECT d.s_title, oc_t_item.*, oc_t_item.s_contact_name as s_user_name,
  MATCH (d.s_title) AGAINST ('"myvi xt"') AS exact_phrase,
  MATCH (d.s_title) AGAINST ('+myvi +xt"') AS both_keyword
FROM (oc_t_item) LEFT JOIN oc_t_item_description as d
  ON d.fk_i_item_id = oc_t_item.pk_i_id
WHERE MATCH(d.s_title) AGAINST('myvi xt' IN BOOLEAN MODE)
ORDER BY exact_phrase desc, both_keyword desc LIMIT 1000
上面的查询将返回下面的结果


因此,问题是结果应该首先按精确短语排序,例如“Myvi XT”然后是“Myvi some text XT”,但我已经使用了
order by exact_phrase desc,两个关键字desc

,默认情况下,MySQL中全文搜索的最小字长为4个字母。这意味着任何较短的内容都将被忽略。以下是相关的:


换句话说,除非您更改了此默认值,否则查询中将完全忽略单词
'xt'

mysql
按您要求的列对其进行排序。有什么问题吗?你能给这两个匹配项赋予一个共同的别名吗?@zerkms结果应该是
Perodua Myvi XT Manual 1.3
Perodua Myvi XT Auto 1.3
然后是
Perodua Myvi 1.3 XT
order by应该首先以
Myvi XT
开头
ft_min_word_len

Command-Line Format --ft_min_word_len=#
Option-File Format  ft_min_word_len
System Variable Name    ft_min_word_len
Variable Scope  Global
Dynamic Variable    No
    Permitted Values
Type    numeric
Default 4
Min Value   1
The minimum length of the word to be included in a MyISAM FULLTEXT index.

Note
FULLTEXT indexes on MyISAM tables must be rebuilt after changing this variable. Use REPAIR TABLE tbl_name QUICK.