Skip Navigation

[Resolved] Search results not 'complete' – added Relevanssi, still only showing some posts

This support ticket is created 2 years, 10 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 - - 9:00 – 13:00
14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 - - 14:00 – 18:00

Supporter timezone: Africa/Casablanca (GMT+00:00)

This topic contains 4 replies, has 2 voices.

Last updated by davidL-20 2 years, 10 months ago.

Assisted by: Jamal.

Author
Posts
#2092685
Screenshot 2021-06-18 at 11.43.50 AM.png

Hello,
We have a directory listing of medical professionals. (Dentist, dermatologist, etc...):
hidden link
I'm hoping to produce search results that show all listings for a specialty, like dermatologists and dentists, for example. Currently, only partial listings are showing. Some listings are not included in search results, even though taxonomy includes the keyword.

For 'Dentists,' for example, 'dental' and/or 'dentist' are included in taxonomy and/or title for each listing. When searching for "dentist", only few of the listings show up:
hidden link
When using a Toolset view to populate a page, all listings show up:
hidden link
(This is what we want the search results to look like.)

How the site is set up:
Toolset is used to create post type called 'listings'.
There are two 'listing' taxonomies: specialty and category.
We have 3 listing levels, which are used to order the results. (Ex. platinum listings how up first, then listed alphabetically, etc...)

So, we added Relevanssi Premium, thinking that perhaps word stemming could help, with synonyms added (ex. dentist = dental).
Toolset custom fields are added to Relevanssi (screenshhot attached.)
We followed Relevanssi documentation for Yoast compatibility, and have this added in functions:
// relevanssi fix for yoast compatibility
add_filter( 'relevanssi_modify_wp_query', 'rlv_meta_fix', 99 );
function rlv_meta_fix( $q ) {
$q->set( 'meta_query', array() );
return $q;
}
// relevanssi fix for toolset post type
add_filter( 'toolset_action_toolset_relevanssi_do_query_before', 'rlv_post_type_filter' );
function rlv_post_type_filter( $query ) {
if ( isset( $_REQUEST['post_types'] ) ) {
$query->query_vars['post_types'] = sanitize_text_field( $_REQUEST['post_types'] );
}
}
I'm sure it's something small we're missing.
Any advice is greatly appreciated.

#2093213

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+00:00)

Hello and thank you for contacting the Toolset support.

As you can read in our documentation article about Relevanssi https://toolset.com/course-lesson/searching-texts-in-custom-fields-with-toolset-and-relevanssi/

Relevanssi is a popular plugin that extends the WordPress native search capabilities as well the free text search used in Toolset custom search. It allows you to search beyond just the post title and content and find texts in custom fields.

This means that Relevanssi will not perform a text search against taxonomies. It will only perform it against the post title, content, and custom fields.

As you can also read before the last section of the article:

Once you add a search filter that includes custom fields, the entire search operation is performed by the Relevanssi plugin, which means that Relevanssi is also responsible for providing the results order. This is why the Views sorting order options are not used. This includes ordering results by distance in a search for posts that include a Toolset Maps address field, where Relevanssi determines the ordering.

This being said, I am not sure how the custom code that you are using will affect the Relevanssi search. I'll need more details to understand it. Can you share the online threads where did you get those custom codes?

To better assist you with this search issue, would you allow me temporary access to your website to check this closely? Your next reply will be private to let you share credentials safely. ** Make a database backup before sharing credentials. **

Can you also provide an example of a result that should appear on the search and that does not show. I'll analyze it and hopefully, I'll find out why it does not.

#2094787

Hi Jamal, Thank you. Credentials sent privately.
Relevanssi did have this in their documentation, so I thought it looked at taxonomy as well. hidden link
Relevanssi was just an attempt to get the 'complete' search results to show, so I don't care if we remove it altogether, if Toolset can work on its own.
Code came from here: hidden link
and here: hidden link
Anyway, here is an example of an 'incomplete' search result:
Search for: 'dentist' (link below)
hidden link
This is what we want the search results to look like (page created with views):
hidden link
Thank you.

#2095605

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+00:00)

Thank you for these details. After reading them, I can tell that:
- Indexing taxonomies with Relevanssi and using Toolset to display the search is probably possible. BUT, I am not sure about it. Basically, Toolset handles the search to Relevanssi, then it applies other search criteria to Relevanssi results(taxonomies, custom fields). However, it seems that Relevanssi will return taxonomy terms as posts. And we are looking for posts. I don't think this will help in this situation.
- The first custom code is not needed. I don't need to analyze it further unless you got results from different post types than "listing". In that case, we can analyze it further and adapt the code to work for this case.
- The second custom code is not needed. That code is relevant when using the "Yoast Local SEO". Your current site does not use it, it uses Yoast SEO.

Toolset, by default, uses the built-in WordPress search, which will look for the exact word inside the post_title, the post_content, and the post_excerpt. If we use Relevanssi, the search can be performed against additional custom fields(Fields of types: Single line, multiline, WYSIWYG), relevanssi won't be able to search inside select/radio/checkboxes/etc fields.

This being said, I think that implementing a text search with nuances(treating dentist, dental, dentures, or orthodontics the same way) won't be easy. It may require some custom code.
For example, you can use a custom code that will always sync a field(excerpt, or custom field) with the taxonomy terms and their nuances/synonyms(selected keywords). The custom code should run whenever a post is saved, and it should update the field with the relevant keywords.
This way, we can use either WordPress search(using the excerpt field), or Relevanssi search(using another custom field).

Another solution would be to NOT use the Toolset text search filter at all. Instead, use a "dummy" search field, then a custom code should check the user keywords and modify the view's query arguments to include the relevant taxonomy terms(category, and specialties).

Personally, because of how WordPress and Toolset works, I would not use a text search at all. I would use taxonomy filters(dropdowns, or checkboxes). And I'll use the text search only if I want to let the users search for names or special keywords in each post's content.

I hope this makes sense to you. Let me know if you have any further questions, or if you want to discuss the suggested custom solutions further.

#2096091

Thank you for taking the time to look at this in detail.
We will look at all options you gave us and figure out how to proceed from there.
Thanks again.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.