Title: Issue with Sorting
Last modified: May 4, 2021

---

# Issue with Sorting

 *  Resolved [pelicanpaul](https://wordpress.org/support/users/pelicanpaul/)
 * (@pelicanpaul)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/issue-with-sorting-3/)
 * Great work however in debugging the sort order I can see the query and there 
   is NO SORT ORDER! You build the priority but NEVER use it.
 * I used this to see your query
 * add_filter( ‘relevanssi_query_filter’, ‘rlv_check_mysql’ );
    function rlv_check_mysql(
   $query ) { var_dump( $query ); exit(); }`
 * <strong>There should be a
    ORDER BY tf DESC;</strong>
 *     ```
       SELECT DISTINCT
       (relevanssi.doc),
          relevanssi.*,
          relevanssi.title * 5 + relevanssi.content * 1 + relevanssi.comment * 0.75 + relevanssi.tag * 0.75 + relevanssi.link * 0 + relevanssi.author + relevanssi.category * 0.75 + relevanssi.excerpt + relevanssi.taxonomy + relevanssi.customfield + relevanssi.mysqlcolumn AS tf 
       FROM
          wp_relevanssi AS relevanssi 
       WHERE
          (
             relevanssi.term LIKE 'bandage%' 
             OR relevanssi.term_reverse LIKE CONCAT(REVERSE('bandage'), '%')
          )
          AND 
          (
       (relevanssi.doc IN 
             (
                SELECT DISTINCT
       (posts.ID) 
                FROM
                   wp_posts AS posts 
                WHERE
                   posts.post_type NOT IN 
                   (
                      'product_variation'
                   )
             )
       ) 
             OR 
             (
                doc = - 1
             )
          )
       ```
   
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fissue-with-sorting-3%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Author [Mikko Saari](https://wordpress.org/support/users/msaari/)
 * (@msaari)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/issue-with-sorting-3/#post-14400418)
 * Don’t worry. The results are still sorted by weight. The TF value there isn’t
   the actual TF value Relevanssi uses; that’s calculated elsewhere. That TF value
   is only used for throttling the results, and you’ll find that if you enable the
   throttle from the Relevanssi settings, the `ORDER BY tf DESC` does indeed appear
   there – it’s needed because then the query continues `LIMIT 500`. Without the`
   LIMIT`, the order of the results doesn’t matter at this point at all, as Relevanssi
   will go through every result.
 *  Thread Starter [pelicanpaul](https://wordpress.org/support/users/pelicanpaul/)
 * (@pelicanpaul)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/issue-with-sorting-3/#post-14403981)
 * thanks. it was actually a conflict with another plugin. took a bit to debug. 
   thanks! [https://wordpress.org/plugins/simple-custom-post-order/](https://wordpress.org/plugins/simple-custom-post-order/)
 * I unchecked the Posts for sorting and search sorts correctly now. Fortunately
   that plugin is not used for Posts
 * SOLVED!
 *  Plugin Author [Mikko Saari](https://wordpress.org/support/users/msaari/)
 * (@msaari)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/issue-with-sorting-3/#post-14405309)
 * Yes, these custom post order plugins tend to mess up the search results.
 *  [ameliacch](https://wordpress.org/support/users/ameliacch/)
 * (@ameliacch)
 * [5 years ago](https://wordpress.org/support/topic/issue-with-sorting-3/#post-14457703)
 * Hola, también tengo un problema con el orden que le da Relevancci a los productos
   mostrados. Solo tiene 2 opciones; ordenar por relevancia o por fecha.
 * En mi empresa trabajamos con un programa interno que gracias a un filtro ordena
   las entradas de una forma específica. Por eso quería preguntar:
 * Como anular la función ORDERBY de relevanssi.. Para que pueda actuar el sistema
   de ordenación que indica nuestro sistema interno.
 * ¿Cuál sería el filtro o función para anular el ORDERBY de relevanssi?
 * Espero respuesta
    Gracias Un saludo
 *  Plugin Author [Mikko Saari](https://wordpress.org/support/users/msaari/)
 * (@msaari)
 * [5 years ago](https://wordpress.org/support/topic/issue-with-sorting-3/#post-14457827)
 * Please start a new thread, instead of posting to another thread that is not related
   your problem. I’ll be happy to help you!
 * Relevanssi must sort the posts somehow, and if you want to sort with a custom
   method, you need to either set the `orderby` query variable to match your needs,
   or if it’s something that can’t be done that way, you need to use `relevanssi_hits_filter`
   to sort the posts. But I’ll be able to help you out more if you tell me how are
   you sorting the posts, now I’m just guessing. So please start a new thread and
   provide more information.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Issue with Sorting’ is closed to new replies.

 * ![](https://ps.w.org/relevanssi/assets/icon-256x256.png?rev=3529670)
 * [Relevanssi - A Better Search](https://wordpress.org/plugins/relevanssi/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/relevanssi/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/relevanssi/)
 * [Active Topics](https://wordpress.org/support/plugin/relevanssi/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/relevanssi/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/relevanssi/reviews/)

 * 5 replies
 * 3 participants
 * Last reply from: [Mikko Saari](https://wordpress.org/support/users/msaari/)
 * Last activity: [5 years ago](https://wordpress.org/support/topic/issue-with-sorting-3/#post-14457827)
 * Status: resolved