在 JOIN 查询中使用 Match ... Against 进行相关性计算 (MySQL)
Relevance calculation with Match ... Against in JOIN queries (MySQL)
我正在尝试使用以下 JOIN 查询获取相关搜索结果:
SELECT
`products`.`id`,
`brands`.`name` AS `brand`,
`products`.`name` AS `productname`,
MATCH (`brands`.`name`) AGAINST ('somebrand someproduct' ) AS brandname_relevance
FROM
`brands`
INNER JOIN
`products` ON `products`.`brand_id` = `brands`.`id`
WHERE
MATCH (`products`.`name`) AGAINST ('somebrand someproduct' ) AS /* AS is highlighted as 'not valid input at this point' */ product_relevance
ORDER BY (brandname_relevance + product_relevance) DESC
然而,正如代码中所指出的那样,'AS' 在此上下文中被 MySQL Workbench 突出显示为无效。查询失败。
两个表中的引擎都是InnoDB,但是MySQL服务器版本在5.6以上,brands.name
和products.name
都启用了FULLTEXT索引。请解释这里的问题是什么。
这是在 where 子句中 - 将其与 select 中的其他字段一起上移。
SELECT
`products`.`id`,
`brands`.`name` AS `brand`,
`products`.`name` AS `productname`,
MATCH (`brands`.`name`) AGAINST ('somebrand someproduct' ) AS brandname_relevance,
MATCH (`products`.`name`) AGAINST ('somebrand someproduct' ) AS product_relevance
FROM
`brands`
INNER JOIN
`products` ON `products`.`brand_id` = `brands`.`id`
ORDER BY (brandname_relevance + product_relevance) DESC
我正在尝试使用以下 JOIN 查询获取相关搜索结果:
SELECT
`products`.`id`,
`brands`.`name` AS `brand`,
`products`.`name` AS `productname`,
MATCH (`brands`.`name`) AGAINST ('somebrand someproduct' ) AS brandname_relevance
FROM
`brands`
INNER JOIN
`products` ON `products`.`brand_id` = `brands`.`id`
WHERE
MATCH (`products`.`name`) AGAINST ('somebrand someproduct' ) AS /* AS is highlighted as 'not valid input at this point' */ product_relevance
ORDER BY (brandname_relevance + product_relevance) DESC
然而,正如代码中所指出的那样,'AS' 在此上下文中被 MySQL Workbench 突出显示为无效。查询失败。
两个表中的引擎都是InnoDB,但是MySQL服务器版本在5.6以上,brands.name
和products.name
都启用了FULLTEXT索引。请解释这里的问题是什么。
这是在 where 子句中 - 将其与 select 中的其他字段一起上移。
SELECT
`products`.`id`,
`brands`.`name` AS `brand`,
`products`.`name` AS `productname`,
MATCH (`brands`.`name`) AGAINST ('somebrand someproduct' ) AS brandname_relevance,
MATCH (`products`.`name`) AGAINST ('somebrand someproduct' ) AS product_relevance
FROM
`brands`
INNER JOIN
`products` ON `products`.`brand_id` = `brands`.`id`
ORDER BY (brandname_relevance + product_relevance) DESC