Skip Navigation

[Résolu] Toolset search not 'complete,' but Relevanssi sorting is not customizable

This support ticket is created Il y a 2 années et 10 mois. 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 3 réponses, has 3 voix.

Last updated by Christian Cox Il y a 2 années et 10 mois.

Assisted by: Christian Cox.

Auteur
Publications
#2098725
Screenshot 2021-06-24 at 10.55.43 PM.png
Screenshot 2021-06-24 at 10.55.56 PM.png

Tell us what you are trying to do?
I want to modify Relevanssi search results sorting the way it can be done with Views.
(ex. listing level (platinum, premium, standard) and then alphabetically.)

Documentation we tried to follow:
Where to put this in Toolset views? --> hidden link
Links here go to 404 page: --> https://toolset.com/forums/topic/alphabetic-sort-with-relevanssi/
Also, in the above post, there is this line from Toolset support:
"You may try above hook and check if that works or use standard wordpress hook pre_get_posts . => https://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts"
The search and results are set via Toolset Views. See screenshots. Where do you put this when using views?
(The whole idea of Toolset was not to custom-code the directory site, so hoping not to hack plugins, if it can be avoided.)

This is an example of listings sorted with views: hidden link
For reference, here is how listings should be ordered:
1. grey background: platinum listings, then alphabetical
2. white background and image on left: premium listings, then alphabetical
3. white background no image: standard listings, then alphabetical.

When using Relevanssi with Toolset, it looks like this:
hidden link
If you scroll down, there are listings with a grey background down below. These should be first.

If we don't use Relevanssi, the results for 'dentist' show only 4 listings, so we don't want to turn it off.

How can we re-order the search results? Any advice is appreciated.

#2099177

Nigel
Supporter

Languages: Anglais (English ) Espagnol (Español )

Timezone: Europe/London (GMT+01:00)

As Minesh pointed out in the ticket you linked to, when you include Relevanssi together with Views, Views hands over the query to Relevanssi, which returns matching results according to its custom weighting rules.

There is nothing that can be done within the settings of either Toolset or Relevanssi to change the ordering of results to match your requirements.

Any solution is going to involve writing some custom PHP code to modify the results after the query has completed.

It looks like you can do that with Relevanssi's own API, as described in the link Minesh shared: hidden link

That post has an example of grouping the results in "buckets" while otherwise maintaining the sort order, and is close to what you are describing.

Alternatively you should be able to use the Toolset API function wpv_filter_query_post_process (https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query_post_process) to do something similar, manually intervening with custom code to rearrange the query results according to your custom logic.

If you didn't use Relevanssi, the search results could locate the search term "dentist" in either the post title or post content according to the settings, so any posts with dentist in either should be included in the result.

Relevanssi adds the possibility to find the search term in custom field values, too.

#2101567

Thank you, Nigel.
Can you recommend a Toolset developer to write code to do this? (using Toolset API function wpv_filter_query_post_process)
I looked under Toolset Contractors and I'm not sure if this is within scope for the group.
Regards,
Roman

#2101655

Hello, we do not have personal relationships with the Contractors you see listed there so we are not informed about their individual specialties and skill sets, beyond the information provided in their profiles. This is something you'd need to discuss and gauge with individual developers.

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