Forums

[Plugin: Relevanssi] Search results return only in descending order (5 posts)

  1. jmania19
    Member
    Posted 2 years ago #

    Is there any way to have the search results returned in Ascending order? I have added this code: <?php query_posts('orderby=title&order=ASC'); ?> before the loop in my Index.php file. When relevanssi is deactivated, the search results return in "ASC" order, when activated , the results return in "DESC" order. Is there a way to modify the code for this?

    Love this plugin...

    Thanks

  2. msaari
    Member
    Posted 2 years ago #

    I suppose so, but why do you need it? Relevanssi returns results in descending order of quality. Changing that order would make the search results less useful.

    In any case, the search results don't use query_posts(), so the reordering needs to be done in some other way. In the latest version, the search results are ordered on row 623:

    arsort($doc_weight)

    If you want to order the entries in different way, that's where you need to make the changes.

  3. jmania19
    Member
    Posted 2 years ago #

    I'm using wordpress as a CMS. I have several products that have similar titles and descriptions. Relevanssi is returning them in a descending order(among themselves) of date published, and I need the first product I entered to show first in the search not last.

    For example: Product names:
    200 Ladder 2 Wire
    200 Ladder 3 Wire

    If I search the term " ladder" the results will show "200 ladder 3 wire first and "200 ladder 2 wire second. I need that to be reversed.

    Thanks for your help...

  4. msaari
    Member
    Posted 2 years ago #

    Relevanssi returns results in descending order of relevance, not date. If two documents are exactly as good (as might be in your case), the order is arbitrary.

    You could try adding an "ORDER BY" clause to the queries. Somewhere around line 510 add:

    $query .= " ORDER BY post_date (or whatever the column is called) ASC";

    or something like that, and you just might get the equal-quality results sorted in ascending order of publication date. I'm not sure, though, haven't tried.

  5. jmania19
    Member
    Posted 2 years ago #

    Tried:
    $query .= " ORDER BY post_date (or whatever the column is called) ASC";
    Didn't work.

    Still 1000 times better than without the Relevanssi plugin.

    Thanks Again

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags