• Hey Mikko,

    First off, I just wanted to say this is a FANTASTIC plugin. After spending a few hours working it into my theme and playing around with it, I simply can’t believe how crippled the default search really is – and how I never realized it. So…thanks!

    I’ve got just three comments I’d like to make:

    1) It would be awesome if you could add the “relevance score” to the posts array returned by a search. Since you’re already returning these scores from relevanssi_search(), it should be a simple matter of adding the following on line 415:
    $post->relevanssi_score = $return[5][$post->ID];

    By doing so, users can then display the scores next to each search result, if desired.

    2) Although the plugin does search in comment content, it doesn’t seem to search commenter names. This is actually one of the features I was really hoping for, as there’ve been quite a few times when I wanted to recall “What was it that so-and-so told me about such-and-such?” So I’d search for that person’s name, hoping to find quick access to their various comments. (In the past, I get around WP’s limitations by just searching via Google :P)

    3) Finally, it would be great to have the ability to set your own orderby. As it stands, whenever Relevanssi is active, search results are ALWAYS returned in order of relevance/score – regardless of the orderby query parameter. However, on my (custom) search page I provide links that allow the users to sort results by date, popularity, # of comments, etc. My initial thoughts were that I’d now be able to add a “Relevance” option (which I’d set as the default) – but since “orderby” is now ignored, I’m basically left with either using relevanssi or ditching the ability to let users sort their results altogether.

    I did spend a good hour or so playing with this, but since I’m unfamiliar with your code I didn’t have much luck. You can see an example of how I have my search-sorting implemented here (Relevanassi is currently off):
    https://www.justin-klein.com/?s=brazil

    Thanks again!

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Mikko Saari

    (@msaari)

    1) is already possible. Choose “Show breakdown” and enter “%score%” in the next input box.

    2) no, commenter names aren’t indexed, but that can certainly be done.

    3) I can see what can be done with this.

    Thread Starter kuprosa

    (@metal450)

    1) Hmm, well that “kinda” accomplishes what I’m after. It does append that info to the excerpt for display, but it’s not directly accessible to allow for display in a custom/different location in the template (i.e. my search results are in a table, and would put the score in a different cell from the excerpt). A way around this would be to do something like strrpos() it back out of the excerpt later – which would work, but isn’t quite as clean as just having access to it as a property of the object directly (like the other info on the post: title, date, etc)

    2 & 3) Sweet, looking forward to it! ??

    Plugin Author Mikko Saari

    (@msaari)

    You’re one lucky man – I’m going to fix all three in the next release, coming later this week. These were all fairly straightforward.

    Thread Starter kuprosa

    (@metal450)

    Excellent – thanks a million dude! ??

    Thread Starter kuprosa

    (@metal450)

    Hey again – so it turns out there’s an issue with the way orderby has been implemented. It occurs when the number of results returned is greater than the number of results to be shown on a page.

    Let’s say we perform a search that returns 20 results. We’re showing 10 results per page and sorting by date. What’s happening is that the query first returns the 10 results with the highest relevance, then these 10 are getting sorted by the “orderby=post_date” after the fact (line 457) – so what you get is two pages where the results on each page individually are in order, but the total results from the two pages are all intertwined. Know what I mean?

    I’ll leave the plugin active for a little bit if you want to see an example; try flipping through to the second page of results:

    https://www.justin-klein.com/?s=stuff&searchsubmit&orderby=post_date

    Plugin Author Mikko Saari

    (@msaari)

    Ah, it took me a moment to figure out what’s wrong with the results, but you’re correct.

    It’s a bit tricky, as earlier in the flow where the ordering should happen, I’m only dealing with document identifiers, not actual objects.

    Plugin Author Mikko Saari

    (@msaari)

    Ok, I think I have it now, but drop me an email to [email protected] and I’ll have you test it before I release a new version.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘[Plugin: Relevanssi] Three Suggestions (score, orderby, comment author)’ is closed to new replies.