Forum Discussion

dhiraj_gophane's avatar
11 years ago

Search all messages based on a Tag

Hi all,

I need a rest API to fetch all the messages in a board having a particular "TAG".

Meaning,
if TAG = "Rest Api"

then 
response should contain all messages in which "Rest Api" is used as a Tag.

5 Replies

  • Hi,

    This feature seems a bit... well hidden indeed. You can find it only via the REST API's search result preview but not the actual documentation results ;)

     

    Basically you simply add the tagging filter "/tagging/for/tags/text/<tag_string>" to your REST API call like this:

     

    http://lithosphere.lithium.com/restapi/vc/boards/id/studio/tagging/for/tags/text/rest%20api/messages/recent

     

    Further reading: http://lithosphere.lithium.com/t5/rest-api/bd-p/developers-rest-api?leaf-id=Category.tagging#Category.tagging.for.tags.text.tag_text

     

    Hope this helps

  • dhiraj_gophane's avatar
    dhiraj_gophane
    Leader
    11 years ago
    Hi Claudius,
    This works for single tag.
    what if I want to filter messages of more than one tags.

    E.g. I want to filter messages having "tag1" or "tag2" or "tag3" or any combination of selected Tags.
  • HaidongG's avatar
    HaidongG
    Lithium Alumni (Retired)
    11 years ago

    Hi dhiraj_gophane

     

    may you try this?

     

    /restapi/vc/search/messages?q=is_root:true%20AND%20tags:(tag1%20OR%20tag2)

    is_root means topics only, no replies, if you want the reply, it will like

     

    /restapi/vc/search/messages?q=tags:(tag1%20OR%20tag2)

     

    I hope that it can help you.

     

     

    Best Regards

    Haidong

     

     btw: if your tag contains space, you will need to use something like

     

    /restapi/vc/search/messages?q=is_root:true%20AND%20tags:(%22test%20space%22)

     

    we are searching for topics with tag="test space" in the above example.

     

     

     

  • dhiraj_gophane's avatar
    dhiraj_gophane
    Leader
    11 years ago
    Hi,
    I'm using same Rest API.
    but for some tags it fetches messages which do not include that Tag.

    E.g. /restapi/vc/boards/id/blogger/search/messages?q=is_root:true%20AND%20tags:(Activity)

    where, Activity is a Tag.

    Is there any other way to fetch these messages by passing tag list?
  • HaidongG's avatar
    HaidongG
    Lithium Alumni (Retired)
    11 years ago

    hi dhiraj_gophane,

     

    can you give exact messages which don't have the tags but got picked up by the REST API call? it sounds a bug for me. you may want to fill a ticket with Lithium Support.

     

    Best Regards

    Haidong