Quantcast
Viewing latest article 1
Browse Latest Browse All 11

Reply To: Poor relevance (possibly mysql-8)

Haven’t managed to figure out any plugins that are affecting this, but have done a bit more fuzzing of the SQL & found some weird results. The query that I previously mentioned – derived from the query that yarrp uses:

SELECT 40775 AS reference_ID, blog_posts.ID, ROUND(0 + MATCH (post_content) AGAINST ('solar cabbage brassicas caterpillars farms panels beneficial may plants butterflies chemical glucobrassicin eggs fields increase insects insect wildlife offer damaged')) AS score
FROM blog_posts left join blog_term_relationships as terms on ( terms.object_id = blog_posts.ID )
WHERE post_status IN ( 'publish', 'static' )
AND post_password =''
AND post_type IN ('post')
AND blog_posts.ID IN ( 33706, 33720)
GROUP BY ID
ORDER BY score DESC;

gives this result

40775 33706 101
40775 33720 101

But if I remove either the GROUP BY or the LEFT JOIN then I get results that look much more like what I expect:

SELECT 40775 AS reference_ID, blog_posts.ID, ROUND(0 + MATCH (post_content) AGAINST ('solar cabbage brassicas caterpillars farms panels beneficial may plants butterflies chemical glucobrassicin eggs fields increase insects insect wildlife offer damaged')) AS score
FROM blog_posts left join blog_term_relationships as terms on ( terms.object_id = blog_posts.ID )
WHERE post_status IN ( 'publish', 'static' )
AND post_password =''
AND post_type IN ('post')
AND blog_posts.ID IN ( 33706, 33720)
ORDER BY score DESC;

removed GROUP BY gives results which look like the GROUP BY is doing the wrong thing

40775 33720 101
40775 33720 101
40775 33720 101
40775 33720 101....
40775 33706 3
40775 33706 3
40775 33706 3
40775 33706 3....

and this

SELECT 40775 AS reference_ID, blog_posts.ID, ROUND(0 + MATCH (post_content) AGAINST ('solar cabbage brassicas caterpillars farms panels beneficial may plants butterflies chemical glucobrassicin eggs fields increase insects insect wildlife offer damaged')) AS score
FROM blog_posts
WHERE post_status IN ( 'publish', 'static' )
AND post_password =''
AND post_type IN ('post')
AND blog_posts.ID IN ( 33706, 33720)
GROUP BY ID
ORDER BY score DESC;

removing the left join gives the answer that I was hoping for all along

40775 33720 101
40775 33706 3


Viewing latest article 1
Browse Latest Browse All 11

Trending Articles