Forum Discussion

FierceMuppet's avatar
FierceMuppet
Contributor
13 years ago

Ssearch for count threads

I can perform a search to get the number of messages with:

 

/search/messages/count?q=date%3A%5B1341341612%20TO%201341946412%5D&collapse_discussion=false

 

What I would like to also get is :

 

  1. A count of threads created in a forum within a certatin period.
  2. A count of views a forum within a certatin period.

I would like to just get a simple count.

 

Ideas?

  • AdamN's avatar
    AdamN
    Khoros Oracle

    To count threads instead of individual messages, you can add the term "is_root:true" to your search query, for example:

    /search/messages/count?q=date%3A%5B1341341612%20TO%201341946412%5D%20AND%20is_root%3Atrue&collapse_discussion=false

     

    This will give you only root messages of threads, which is equal to the number of threads from that period of time.

     

    To get the number of views for a forum for a certain period, I'd suggest using the "metrics" method for a board. There are a few different views metrics, so I'd suggest reviewing the metrics in the admin to get the name of the exact metric you're interested in. The call would look something like (assuming you wanted message views):

    /boards/id/YOUR BOARD ID/metrics/name/message_views

     

    This call also accepts a date_start and a date_end parameter to specify the date range.

    • The "is_root:true" query parameter didn't work for me (e.g. adding it changes the count to zero :( ). But isn't "collapse_discussion=true" exactly returning the number of threads when combined with /count ?

      • AdamN's avatar
        AdamN
        Khoros Oracle

        Hi Claudius,

         

        Strange that "is_root:true" wasn't working for you. Were you using it as part of the q parameter? For example (unencoded):

        http://lithosphere.lithium.com/restapi/vc/search/messages/count?q=is_root:true

         

        I tend to prefer the "is_root:true" with collapse_discussion=false approach when searching for threads, since it gives you back the root message for each thread rather than the best match per thread. This ensures that the root message occured within the desired time range, which I'm assuming is what is wanted here. With collapse_discussion=true, it will return a result if any message in the thread matches the search criteria (ie. one of the replies falls in the selected time range), so the results may be skewed. 

         

        I suppose it really depends on what you want to count... Thread being started in the time range vs. thread activity in the time range.