CMS Filter: Results by relevance

Hi!

I’m using the Finsweet CMS filter attribute and want to display search results by relevance. For example, if I type the word “partnership” in the search box, I want the results that contain the word “partnership” most frequently to appear first.

I use rich text elements inside CMS items and have them hidden. While search results do appear, they are not sorted by relevance. Instead, they’re displayed in the order they were created in the CMS.

How can I sort the results by relevance?

Hey @isoup363! I believe we currently do not have a native option to sort by relevance, maybe we could accomplish something with the API :thinking:

Could you share a link for me to test?

Hello @Support-Luis, could you please explain a bit more on this issue?
Is it possible to do with API? How i could access it?

Unfortunately I can’t send you a link to the project, but I really want to understand if it’s possible to do this with the great Finsweet attributes, this feature seems obvious to me.

It could be possible if we sort the items by the amount of keyword “hits” we get for each item!

The documentation of the API is here

We could add a beforeRender hook to sort the items by relevance.

In pseudo code:

  1. Get keyword
  2. Count the amount of “hits” a keyword has on the RTE
  3. Sort items by this counter
  4. Trigger a render event with the sorted array

Let me know if this makes sense!