Continue reading Debugging with Query Monitor

Debugging with Query Monitor

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,…

Read more Debugging with Query Monitor 0 Comment on Debugging with Query Monitor
Continue reading Exact matches for short search terms

Exact matches for short search terms

Is is possible to set Relevanssi in a way that it would return only perfect matches for queries up to 3 characters, but any words that starts with the queried term if it has 4 characters or more? – Originally asked here Yes, but it requires a bit of code. Add this to your site and…

Read more Exact matches for short search terms 0 Comment on Exact matches for short search terms
Continue reading Wildcard matching

Wildcard matching

Relevanssi Premium 2.10.2 introduces a new way to search: wildcard matching. Once the wildcard matching is enabled (it is disabled by default), it introduces two new operators: * and ?. Using the wildcard operators The * operator replaces zero or more characters, so searching for w*ess would match “wilderness”, “witness”, “WordPress” and also “wess”. The…

Read more Wildcard matching 2 Comments on Wildcard matching
Continue reading Relevanssi and languages

Relevanssi and languages

…problems, the lack of distinct words in these languages is a problem for Relevanssi. Relevanssi works by splitting the posts into words at spaces and then counting how many times those words appear. Since Chinese and Japanese texts don’t have spaces separating words, Relevanssi can’t do this. As a result,……Relevanssi can search for Chinese and Japanese characters or character sequences, especially if you enable one-character words and inside-word matching in Relevanssi settings. Still, since the weights for the posts are essentially random, the results won’t be of high quality. Unfortunately, making the search work well in Chinese, Japanese and……Relevanssi can handle just about anything you throw at it – you can even search for emojis. UTF8 is the standard in WordPress, and you generally don’t have to worry about it. Words: bad news for Chinese and Japanese While Relevanssi can read Chinese, Japanese and many other characters without…

Read more Relevanssi and languages 17 Comments on Relevanssi and languages
Continue reading Indexing only attributes from shortcodes

Indexing only attributes from shortcodes

…do I go about this? – Duke at Remove shortcode but keep content in X parameter You can’t do this using the Relevanssi shortcode removal because that’s a binary operation: the whole shortcode is kept or removed, and there’s no way to keep only part of the shortcode. However, you…I need to add some custom shortcodes to the list of the “removed” ones (so they don’t show in plain text in the results). However, some of them are built like [shortcode_name text=”Need to keep this in results”] and I would like the content in the text parameter to stay in the results. How……the “text” attribute from the shortcode * * @param string $content Post content * * @return string Post content with the shortcode replaced with just the “text” attribute content. */ function rlv_shortcode_attribute( $content ) { return preg_replace( ‘/\ /im’, ‘\1’, $content ); } Since this particular case was about a…

Read more Indexing only attributes from shortcodes 0 Comment on Indexing only attributes from shortcodes
Continue reading Boosting shorter posts with higher keyword density

Boosting shorter posts with higher keyword density

By default, Relevanssi tends to prefer longer posts. The default TF × IDF weights Relevanssi uses simply count the term frequency, ie. how many times a word appears in the post. That prefers longer posts as they usually have the search term appear more often. However, a 500-word post with 15 search term appearances might…

Read more Boosting shorter posts with higher keyword density 0 Comment on Boosting shorter posts with higher keyword density
Continue reading WooCommerce: Return only exact matches for SKU searches

WooCommerce: Return only exact matches for SKU searches

This little filter function works on relevanssi_hits_filter. When a search query is made that matches an SKU (or any other custom field, but SKUs are the most likely scenario here), only results that match the SKU will be returned. For this to work, Relevanssi must be set to index the…

Read more WooCommerce: Return only exact matches for SKU searches 1 Comment on WooCommerce: Return only exact matches for SKU searches
Continue reading Using phrases in Related posts searches

Using phrases in Related posts searches

I have a book review site where I’m using Relevanssi Premium and the Related posts to highlight related book reviews. The reviews have multiple taxonomies used for the related posts: tags, book author, series, characters, and places. Messy relations The problem is, with the default settings, the Related posts get a bit messy. This site…

Read more Using phrases in Related posts searches 0 Comment on Using phrases in Related posts searches
Continue reading Relevanssi indexes excluded posts

Relevanssi indexes excluded posts

Sometimes it can happen the search results include posts from a post type that has been excluded from the index. When that happens, here are things you can check. Are you using Relevanssi? It’s possible your search results are not coming from Relevanssi. The quickest way to check is to use the Relevanssi admin search…

Read more Relevanssi indexes excluded posts 3 Comments on Relevanssi indexes excluded posts