Skip to main contentSkip to footer

Query Monitor is by far the best thing for a WordPress developer. It’s billed as the “Developer Tools panel for WordPress”, and that’s a good way to put it. If you’ve ever used the browser developer tools, you know what to expect.

Query Monitor is a good way to figure out problems in Relevanssi searches, as it’s the easiest way to see the database query Relevanssi is doing. That’s a good way to find out if there are unexpected filtering rules or something like that blocking posts from the results.

After you install Query Monitor from the plugin repository and activate it, it shows up in your admin bar:

Query Monitor appearance in the admin bar
Query Monitor output marked with the red border. The output includes the page generation time (0.43s), peak memory use (8,452kB), number of database time spent (0.0217s) and the number of database queries (50 queries). Very helpful for optimizing your site performance!

Clicking the admin bar output opens up the Query Monitor panel and from there, you can access all sorts of information. When debugging Relevanssi searching issues, we’re mostly interested in the Queries part, and you can set the “Caller” to relevanssi_search() to exclude all non-Relevanssi queries.

Query Monitor Queries panel

The highlighted query that begins with SELECT DISTINCT(relevanssi.doc) is the main Relevanssi search query and the one we’re interested in, as all search filters that affect the search query (taxonomy filters, custom field filters, date filters and so on) will appear there. This here is a very basic query, it just looks for posts with the search term “copy”.

This query can also point out some problems with the weights. The weights for titles, content and so on appear in the query: you can see in the beginning there’s relevanssi.title * 5 + relevanssi.content * 5 + relevanssi.comment * 0.75 and so on. This means the titles and content have a weight of 5, while comments have a weight of 0.75. Having a 0 weight for titles or content is a fairly common problem that can be spotted from the query.

This is the most relevant part in Query Monitor for Relevanssi debugging use, but the plugin is a treasure trove of useful debugging information, and every WordPress developer should always use this plugin.

Your account

Not logged in. Log in to see your license details.

Search

Popular Resources

WooCommerce: Popularity and price sorting

Many WooCommerce users use search sorting that allows users to sort by popularity or price. Unfortunately, while Relevanssi works fine with WooCommerce, those sorts do not work. Relevanssi doesn’t know about price or popularity, and the sorting assumes there’s a default WP search underneath. Relevanssi doesn’t do meta field sorting…as easily as the default WP search does. This function handles price, popularity and rating sorting: add_filter( ‘relevanssi_orderby’, ‘woocommerce_relevanssi_orderby’ ); function woocommerce_relevanssi_orderby( $orderby ) { if ( in_array( $orderby, array( ‘price’, ‘price-desc’ ), true ) ) { global $wp_query; $orderby = ‘meta_value_num’; $wp_query->query_vars[‘meta_key’] = ‘_price’; } if ( ‘price’ ===…

Italian plurals

…or “che”, the ending is changed to “ga” or “ca”, respectively. Then if the word is over three letters long, a final “a”, “e”, “i”, or “o” is stripped. Now plural and singular forms are considered the same in the search. Remember to rebuild the index after adding this function!…

Related Posts:

Currently there are no related posts available.

Comment Section:

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed