Plugin Author
Ajay
(@ajay)
The plugin uses the fulltext search feature of mySQL for the weighting.
I’m not sure if a test term like “testabcdefg” would give a proper result given it isn’t a proper word. It doesn’t use a recurring weight i.e. 5x in the content doesn’t necessarily mean the weight is 5.
The plugin first finds the relevant posts and the colouring only takes place when the search results page is rendered.
The best way I debug this is to install Query monitor and view the queries generated on the search results page. And, then test this via Adminer or phpMyAdmin.
Hello Ajay,
Thanks for your quick reply.
As suggested I have installed Query Monitor, and ran the following query on my database:
SELECT DISTINCT ID, (MATCH(post_title) AGAINST ('test' ) * 1 ) + (MATCH(post_content) AGAINST ('test' ) * 1 ) AS score
FROM wp_posts
WHERE 1=1
AND MATCH (post_title,post_content) AGAINST ('test' )
AND (post_status = 'publish'
OR post_status = 'inherit')
AND wp_posts.post_type IN ('post')
ORDER BY score DESC
I also used different search keywords, like: “testabcdefg”, “mind” or “mindmap”. This are all keywords that return results on the search page.
I’m always getting an empty dataset, on every query I run.
I assume the plugin gives every post a score of 0, and afterwards they probably get ordered on the time the posts were created.
I infer this from:
SELECT DISTINCT ID, 0 AS score
FROM wp_posts
WHERE 1=1
AND ( ((post_title LIKE '%test%')
OR (post_content LIKE '%test%'))
OR (post_title LIKE '%test%')
OR (post_content LIKE '%test%') )
AND (post_status = 'publish'
OR post_status = 'inherit')
AND wp_posts.post_type IN ('post')
ORDER BY post_date DESC
Seeing this query, another questions arises: why are you double checking for post_title and post_content?
Not sure where to go from here, since it seems the query is not working.
Kindly awaiting your reply,
Plugin Author
Ajay
(@ajay)
Hi, you are right on the flow. The plugin tries to find results by full text first, then full text with boolean and then finally using a text match.
The last query first checks for posts with both post content and title results and roles down to either. It’s partially how WordPress handles searches.
Have you tried running normal searches on your blog rather than just test ones?
Also, can you check that a full text index does exist?
I have tried running normal searches (without the plugin enabled) if that’s what you mean, and nothing really changes. The only visible change is the highlighting of the keywords in the results.
Not sure where to look for the full text index, but I’m still pretty sure it doesn’t exist.
How do I fix this?
Plugin Author
Ajay
(@ajay)
In phpmyadmin you can find the indices at the bottom of the structure view of the posts table. It’s usually hidden, so you need to unlike this.
You will find 3 indices, one for post title, one for post content and one for both.
I checked, and I indeed have 3 indices, bsearch, bsearch_title and bsearch_content.
jelle-roorda.nl
You will be able to enter with
user: [moderated]
pass: [moderated]
Plugin Author
Ajay
(@ajay)
Hi, please do not post any access details in the forum. It’s a public place and you’re allowing anyone to see them.
I ran searches for online, khan academy, toolkit, etc and these display search results properly. Even test ran a proper result.
I’m a bit confused as to what results you’re expecting to see?
As I mentioned in my first post, the searches are indeed displaying properly, the only problem is that the searches are not displayed ordered on relevance.
Because the following query always returns 0 rows:
SELECT DISTINCT ID, (MATCH(post_title) AGAINST ('*****' ) * 1 ) + (MATCH(post_content) AGAINST ('*****' ) * 1 ) AS score
FROM wp_posts
WHERE 1=1
AND MATCH (post_title,post_content) AGAINST ('*****' )
AND (post_status = 'publish'
OR post_status = 'inherit')
AND wp_posts.post_type IN ('post')
ORDER BY score DESC
Replace ‘*****’ by any search term.
Plugin Author
Ajay
(@ajay)
Hi,
To be honest, I’m not at all sure as to why the match doesn’t work at all.
Can you run this query? I’m removed the criteria for the match. So it should pull all the posts and throw a score against this.
SELECT DISTINCT ID, (MATCH(post_title) AGAINST ('*****' ) * 1 ) + (MATCH(post_content) AGAINST ('*****' ) * 1 ) AS score
FROM wp_posts
WHERE 1=1
AND (post_status = 'publish'
OR post_status = 'inherit')
AND wp_posts.post_type IN ('post')
ORDER BY score DESC
This is not returning any rows either
Plugin Author
Ajay
(@ajay)
I’m wondering if the post type is the issue. What are the various post types that you see in the better search settings page. What happens when you select them all?
It was indeed the post type. After selecting all it works as it’s supposed to be.
Plugin Author
Ajay
(@ajay)
Thank you for confirming. Glad to know we resolved this!