Forum Discussion

iahiqosolutions's avatar
13 years ago

REST API: Sorting messages by replies count works incorrectly

Hello guys,

 

It seems that sorting by replies count works incorrectly,

I use the following request:

 

http://%Community Name%.stage.lithium.com/restapi/vc/categories/id/%Category Id%/search/messages?page=1&page_size=10&q=the&restapi.format_detail=full_list_element&search_type=thread&sort_by=-replies

 

This request returns 10 messages with following ids:

  • 443
  • 587
  • 351
  • 671
  • 499
  • 143
  • 485
  • 655
  • 25
  • 397

For each of these messages I get count of replies by the following request:

http://%Community Name%.stage.lithium.com/restapi/vc/messages/id/%Message ID%/replies/count

 

And this returns the following results:

 

  • 443 (14 replies)
  • 587 (13 replies)
  • 351 (9 replies)
  • 671 (9 replies)
  • 499 (9 replies)
  • 143 (10 replies)
  • 485 (7 replies)
  • 655 (7 replies)
  • 25 (6 replies)
  • 397 (4 replies)

As you can see something wrong with message order, because message with id 143(10 replies) is placed only on the 6 postion.

Can someone explain me such strange behavior?

2 Replies

  • DougS's avatar
    DougS
    Khoros Oracle
    13 years ago

    The search all you are making is not sorting by number of replies (in fact, I don't believe we have a way to sort search results by number of replies).  I believe the sort_by=-replies sorts the results by most recent comment, and since you specified search_type=thread (you are only searching for threads), this gives you all threads with your search term, sorted by thread with the most recent replies.

  • Hello DougS,

    Thank you for your response!
    By the way could you please recommend me articles or something else where I can find documentation about search sort types?