All Low add-ons are now owned by EEHarbor. Read the blog post.

Support archive

Re-sort the search results based on exact match in {title}

Gilbert Lin 1 May 2020 20:04 question, complete

Hello there,

First of all, great product and I really enjoy working with it.

I know you've answered related questions about why sometimes the weight of fields doesn't work as expected when printing the results. I know that's due to the database's search mechanism.

Question: if I want to add a function to re-sort the entries and put the ones that have exact match of the search string in the title field to the front of the results, where would I be adding that? Thanks!

Replies

  1. Low 2 May 2020 12:05

    Well, there's the keywords:match parameter. If you set that to "title", entries where the keywords exactly match the entire title will be pushed up.

    If you want the same behaviour for partial matches in the title, you're probably better off creating your own filter that runs after the keywords filter and checks for partial matches in the title and sorts results accordingly.

  2. Gilbert Lin 25 May 2020 23:31

    I had coded my own filter. However, I found a weird behaviour (or maybe I missed something in the documentation) with the keyword:match filter. When I set it to keywords:match="title" and the keywords being "world religion in a new era" the match doesn't work. Took me sometime to find that the "a" is removed from the $keywords here

    IF({$field} = '{$keywords}', 1, 0) AS 'match'
    so there's never a match. Is this intended?

  3. Low 26 May 2020 11:36

    Hmm, looks like it's using the cleaned up keywords rather than the raw input. I can understand how that can be confusing. Also discovered a bug where the matching won't trigger correctly when a non-fulltext search is triggered. Will look into fixing that.

  4. Gilbert Lin 26 May 2020 17:19

    Yeah I think it might be easier to have an extra variable $raw_input or some sort. Thanks!

  5. Gilbert Lin 12 Jun 2020 18:53

    Hello there,

    Any updates on this?

  6. Low 16 Jun 2020 11:46

    Just released v6.2.1 which should address this issue.

  7. Gilbert Lin 16 Jun 2020 18:19

    Nice! The raw keywords worked!