I am using a View with a search filter on this page: hidden link I also have Relevanssi installed on our site. I've checked all of the Relevanssi settings and everything looks good, I have given a lot of weight to the title of the post vs content, and I have rebuilt the index.
The problem is that the search results are terrible. I can search for a word and the top 10-20 results don't even contain that word. However, when I go to Dashboard > Admin Search the results are perfect. How can I get the View search results closer to what I see on the Admin Search?
I have weighted the title so much higher than the content in Relevanssi's search setting that this doesn't make sense. Are these settings not applied to the Toolset search?
Well - you will require to check this with Relevanssi support as when you use Relevanssi integration Toolset's role is just passing the whole query to Relevanssi and Relevanssi handles further.
I also noticed the all posts are not indexed. It get stuck after:
Indexed 316 posts (total 624), processed 624 / 1287.
Please get in touch with Relevanssi support and share what is your expected output and they will help you to adjust the relevanssi query accordingly.
I asked the makers of Relevanssi about this first, and they said they didn't know anything about Toolset or how it handles the query or results, which is why I came here. Can you please tell me in a more specific and technical way how Toolset interacts with Relevanssi so I can tell them, and then ask them what might be the problem?
when you use the Relevanssi integration the search query will be passed over to Relevanssi, having said that relevenssi will the reponsible to handle, build and run the query.
I see there are number of hooks available as per their doc:
I see the indexing issue on the staging site, I can't explain that, but on the live production site there is no indexing issue. It has indexed all pages, posts, and the 'film' custom post type.
Relevanssi support has walked me through a few different searches of the site. The problem is that the site results outside of Toolset are all working as expected. In fact, admin search and basic site search of a word in the 'film' post type get the same excellent results. The results in the Toolset View are almost a complete inversion of the admin search results-- those posts that appear at the top of the admin search are at the very bottom of the View search. It's not a complete 1:1 inversion, but very close.
The only ordering options in Relevanssi are to order by relevance or post date, and I have it set to 'relevance' (the default). There is no "inverse relevance" option, but that appears to be what the View is doing with the results it is getting from Relevanssi.
As I shared details before - when you use view with text search the search query will be managed by Toolset
But when you use Toolset with Relevanssi integrtion, the search query will be passed over to Relevanssi and managed by Relevanssi, having said that relevenssi will the reponsible to handle, build and run the query.
So, you have two option, either use only Toolset and I will try to help you to match exact result as per admin search (in this case you will have to exclude the Relevanssi) and if you use only Toolset, it can search either in post title only or post title and content.
If you want to keep using Relevanssi, then the result currently you have you have to deal with that and contact Relevanssi for further support to match your result and check with them how to sort/orderby result.
Minesh is not available today, he will be available tomorrow. But for now, To scope the code to only a specific Toolset View, you’ll need to hook into Toolset’s wpv_filter_query filter, because that’s the point where Toolset builds the query arguments for each View. There, you can check the $view_id and conditionally apply the Relevanssi filter only for that View.
Here’s an example pattern:
add_filter( 'wpv_filter_query', function( $query_args, $view_settings, $view_id ) {
// Change 1234 to your actual View ID
if ( (int) $view_id === 1234 ) {
add_filter( 'relevanssi_modify_wp_query', 'my_custom_relevanssi_order', 10, 1 );
}
return $query_args;
}, 10, 3 );
function my_custom_relevanssi_order( $query ) {
$query->set( 'orderby', array( 'relevance' => 'desc' ) );
return $query;
}