I have the following query which is doing a search against the keywords in Natural Language mode,
However I found that although I am using " Distinct
" keyword to select Unique url, its not working, I get results with the same url a number of times, which is confusing me,
Also I have tried the " Group By
" url, however issue is then " ORDER
" of the mysql results changes (as you know MYSQL orders results in MOST RELEVANCE first in Natural Language Search)
Any other ways to achieve this
Query is
SELECT DISTINCT `url` , `search_id` , `total` , `keyword`, `title`, `description`
FROM search
WHERE MATCH (`keyword`,`title`,`description`,`url`) AGAINST
('".$natural_keywords."'
IN NATURAL LANGUAGE MODE)
-- GROUP BY url
-- ORDER BY score DESC
LIMIT ".$page.",10
i solved this problem using relevance as below
SELECT `url` , `search_id` , `total` , `keyword`, `title`, `description`,
(
(
0.9 * (MATCH(`title`) AGAINST ('".$keywords."' IN BOOLEAN MODE))
)
+
(
0.6 * (MATCH(`description`) AGAINST ('".$keywords."' IN BOOLEAN MODE))
)
+
(
0.3 * (MATCH(`keyword`) AGAINST ('".$keywords."' IN BOOLEAN MODE))
)
) AS relevance
FROM search
WHERE MATCH (`keyword`,`title`,`description`,`url`) AGAINST
('".$natural_keywords."'
IN NATURAL LANGUAGE MODE)
-- GROUP BY url
ORDER BY relevance DESC
LIMIT ".$page.",10
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.