Automattic / WP-Job-Manager

Manage job listings from the WordPress admin panel, and allow users to post jobs directly to your site.
https://wpjobmanager.com
GNU General Public License v3.0
895 stars 366 forks source link

Keyword Search: Meta queries don't match WP_Query search & Support Modifiers for AND/OR/EXACT #2749

Closed tripflex closed 1 month ago

tripflex commented 5 months ago

I've had numerous clients request some functionality enhancement to the keyword searching functionality, mainly around the fact that every word is searched using a LIKE comparison operator so php developer would return any results for php AND any results for developer

When this is then checked for post meta, a LIKE is generated using %php developer% which is a bit inconsistent with how the s parameter works for searches. So the native s parameter in WP_Query does %php% and %developer% the meta queries added do %php developer%

What i've seen the most request for is being able to do something like you can on Google where you use quotes to define a specific term wanted, so "php developer" would return ONLY results that match on php developer (sorta how meta queries are handled now, but s queries are not)

May be worth looking at revamping the keyword searches to support modifiers or at a minimum keep things consistent between s and the meta queries generated.

My initial guess would be to pass exact to WP_Query (i think this just tells not to do wildcard % and doesn't split the keywords by spaces) and maybe could do this by checking for quotes around values (strip those out and then set exact on WP_Query)