Tech Support Challenge

MySQL Challenge 1

A customer is working on a custom solution for their search, but the MySQL query they crafted returns an error when executed:

FROM wp_searchwp_tokens t
LEFT JOIN wp_searchwp_index i
AND i.source IN ('', '','post.product')
AND t.token IN ('make')

a) Please summarize the steps you took to investigate the issue.
b) Please compose a response to the customer that relays your findings and recommendations.

MySQL Challenge 2

How many tables are used in the following query?

SELECT SQL_CALC_FOUND_ROWS,s.source,, SUM(relevance) AS relevance
(SELECT, s.source,, s.attribute,
((SUM(s.occurrences) * CASE
WHEN ((s.source = ''
AND (s.attribute IN ('title','slug','excerpt')))) THEN 300
WHEN ((s.source = ''
AND (s.attribute IN ('content')))) THEN 1
END)) AS relevance
FROM wp_searchwp_index s
LEFT JOIN wp_posts s1 ON (s1.ID =
LEFT JOIN wp_posts AS swpwcposts ON swpwcposts.ID =
AND 1=1
AND s.token IN (73,554)
AND 1=1
AND ((s.source = ''
AND (s.attribute IN ('title','content','slug','excerpt'))
AND ((`s1`.`post_type` = 'post')
AND (`s1`.`post_status` IN ('publish')))))
GROUP BY,s.source,s.attribute, AS s
LEFT JOIN wp_posts s1 ON (s1.ID =
LEFT JOIN wp_posts AS swpwcposts ON swpwcposts.ID =
AND (SUBSTRING(s.source, 1, 5) != 'post.'
OR (SUBSTRING(s.source, 1, 5) = 'post.' AND != '0'))
GROUP BY,s.source,
HAVING relevance > 0
ORDER BY relevance DESC
LIMIT 0,10

Hook Challenge 1

A customer would like to use the code example from the searchwp\query\args Search WP hook page.
But they need help changing the code to work only for logged-out users.

a) Please explain how you’d customize the code example to meet the customer’s request.
b) Please compose a response to the customer.

WP_Query challenge

Build a WP_Query to get the IDs of all media files that are attached to a post.

Bonus Challenge (optional)

This challenge is optional and has an increased difficulty.
Solving this challenge gives a candidate more points but a candidate is not required to do it.

SearchWP indexes the site and tokenises content (breaks it into single tokens or keywords).
It uses spaces, punctuation and special characters as token boundaries.
So if it had to index a camera focal length like f/0.95 it would break this into the following tokens: f, 0 and 95.

To prevent this from occurring SearchWP uses regex patterns to find keywords that should be considered as a single token including the special characters.
So with the correct regex pattern we could tell SearchWP that f/0.95 is a single token and should not be broken into multiple tokens.
A searchwp\tokens\regex_patterns hook (documented here) is available to add custom regex patterns for this.

Let’s suppose we have a photographer website and we want to instruct SearchWP to consider camera focal lengths intact as a single token. Examples of focal lenses are below:


What regex pattern can be used to match all possible focal lengths and how would we use the above hook to add the correct regex pattern?

Want to make your search awesome right now?

More than 30,000 sites have chosen SearchWP!

You can utilize all of the content that’s gone unrecognized by native WordPress keyword search instantly with SearchWP.

Get SearchWP for just $99

  • Committed Support
    If you need help, support is fast, friendly, and here for you
  • Streamlined Setup
    Installation and setup that’s optimized for speed
  • Great Documentation
    Helpful, clear, and usable documentation is a priority

See what SearchWP customers have to say

  • “the plugin does exactly what it says with a dedicated support! highly recommended !”

  • “Powerful and flexible; excellent for building custom search engines and extending search across custom post types and fields. Intuitive and user-friendly interface; lots of add-ons; excellent API, documentation, and customer support to boot.”

  • “The SearchWP plugin is a necessity for anyone building out document libraries because it seamlessly searches PDF files. The Search Term Highlighting add-on is also pretty slick.”