Forum Discussion

vidhyut_cisco's avatar
12 years ago

Need search results sorted

Hi,

 

I am using the api "/search/messages?q=${SRIDs}&f=tags&restapi.response_style=view" to search messages in the community. Is there a way to get the results sorted either in ascending or descending order? Thanks.

 

Regards,

Sethuraman.AR

4 Replies

  • AdamA's avatar
    AdamA
    Khoros Oracle
    12 years ago

    Hello,

     

    You can use the following query parameter key/value to sort by descending date:

     

    sort_by=-topicPostDate

     For ascending you can remove the '-' from query param value. Here are some other query param values you can use for sorting:

     

    • topicViews
    • topicKudos
    • replies
  • Ordering by (-) topicKudos doens't seem to work.. (querying search/messages). Errocode = 100. Can you please elaborate?

  • ChhamaJ's avatar
    ChhamaJ
    Khoros Staff
    11 years ago

    Actually, its topicKudosCount 

    On the other hand, how or by what criteria are you trying to sort the messages? 

     

    Regards,
    Chhama

  • PieterOtten's avatar
    PieterOtten
    Helper
    11 years ago

    I was trying to get the most popular topics in the last X days. Popular in this case meaning most views, as most reactions can be abused and most kudos isn't usefull because kudos aren't used often by our forum users.

     

    I've came up with the following link to use, which seems to work good:
    ..restapi/vc/search/messages?q=(is_root:true%20AND%20date%3A%5B1398089232%20TO%201400681242%5D)&sort_by=-topicViews&collapse_discussion=true

     

    The datefilter is used to get topics not more than 1 month old.

     

    Any further suggestions on this query?

     

    Overall I'm missing documentation on the query and sort possibilities. Only by searching these forums I've found the "is_root:true", date-filter and possible sortyBy values... Too bad!