Bug #15648
closedGroup forum search doesn't always return correct results
0%
Description
From #15646:
2. Failed Search: My browsing through the forum post list was occasioned by a failed search. I was looking for "excellence fee" in this private group - https://commons.gc.cuny.edu/groups/ma-in-digital-humanities-cuny-graduate-center . When I searched for those words, with or without quotation marks, nothing came up. But, as evidenced by this post -- https://commons.gc.cuny.edu/groups/ma-in-digital-humanities-cuny-graduate-center/forum/topic/student-tech-fee-excellence-fee-opportunities-2/ -- there was a post with the subject "excellence fee" included (fyi, I tried both "fee" and "fees")
Ray, could you have a look? I wonder whether it has to do with private posts.
Related issues
Updated by Boone Gorges over 2 years ago
- Related to Feature #15646: Forum improvements added
Updated by Raymond Hoh over 2 years ago
This bug is caused when searching for multiple terms due to unnecessary sanitizing of the search terms. I've just fixed this in the following commit: https://github.com/cuny-academic-commons/cac/commit/a46e75d365d46ab95adf76215a5250d694b5fffb. This should fix the immediate issue. I'm going to push this fix to 1.19.x
branch as well.
As far as searching with quotations around the search term, forum search (and WordPress) doesn't support this functionality natively. Was surprised to find that no-one had attempted to add this functionality, so I've written some code to allow searches wrapped with double quotations here: https://gist.github.com/r-a-y/f66042d63970a1058a4e380e31f8463b. What I'm doing in this code snippet is removing double-quoted search terms from the 's'
field and then appending the double-quoted search term to the end of the SQL query. Boone, can you take a look to see if there are any problems with this approach before I commit this? I've opted to do this sitewide, rather than limit this functionality to forum search because I think this would be really beneficial on the frontend as well as in the admin area. But if we wanted to only limit this to forum search, we could do that as well.
When combined with WP's native exclusion search terms support, it would be possible to do a search like this:
"match this" -notthis -orthis
So the search would include posts for match this
exactly and omit posts including notthis
or orthis
. This could really help users trying to find something specific.
Updated by Boone Gorges over 2 years ago
Thanks for the digging here, Ray. The general approach looks good to me, and I agree that it should be useful sitewide.
This is only sort of related, but I wrote something similar for the OpenLab a few years ago https://github.com/openlab-at-city-tech/openlab/commit/e8212e6d91f60bafea9ffa0c202252d9e86bab38 - it adds support for quoted search and also wildcards for BP search.
Updated by Raymond Hoh over 2 years ago
- Status changed from New to Staged for Production Release
I've added the code snippet here: https://github.com/cuny-academic-commons/cac/commit/2d4cb987d1b8ec0671dfc4d8ea2f3b070b2b6d52.
Double-quoted searches can now be tested on cdev. Try in a group forum or if you are an administrator of a sub-site, try doing a double-quoted search when on the "Posts" admin dashboard page. On the "Appearance > Widgets" page, you can also add the "Search" widget to your site; then on the frontend, you can use the Search widget to do a double-quoted search as well.
Updated by Boone Gorges over 2 years ago
- Status changed from Staged for Production Release to Resolved