cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

Do a stream query with tags filter

cbaurand
11-Garnet

Do a stream query with tags filter

Hi,

 

According to this documentation,  https://support.ptc.com/help/thingworx_hc/thingworx_8_hc/en/index.html#page/ThingWorx/Help/Composer/Things/ThingServices/QueryParameterforQueryServices.html,

we should be able to do a query with those filters:

TAGGED or NOTTAGGED filter
var query = {
            "fieldName": "tags",
            "type": "NOTTAGGED",
            "tags": [
              {
                        "vocabulary": "Applications",
                        "vocabularyTerm": "Testing"
              },
              {
                        "vocabulary": "Plants",
                        "vocabularyTerm": "Sedona"
              }
            ]
};

or with those:

var query =
{
    "filters": {
        "type": "And",
        "filters": [
            {
                "type": "GT",
                "fieldName": "Duration",
                "value": "12"
            },
            {
                "type": "TaggedWith",
                "fieldName": "tags",
                "tags": "MaintenanceIssues:PowerOutage"
            }
        ]
    }
}; 

But it seems that none of them works with tags. Can someone confirm this troubleshouting?

 

Thanks.

3 REPLIES 3
mnarang
17-Peridot
(To:cbaurand)

I have something like your second query working absolutely fine. Can you replace "TaggedWith" to "TAGGED" in your second query and test it again ? In your case it should be like:

 

var query =
{
"filters": {
"type": "And",
"filters": [
{
"type": "GT",
"fieldName": "Duration",
"value": "12"
},
{
"type": "TAGGED",
"fieldName": "tags",
"tags": "MaintenanceIssues:PowerOutage"
}
]
}
};

 

TomasCharvat
14-Alexandrite
(To:mnarang)

Hello  mnarang,

 

Thanks for this hint,

I always tried to use TaggedWith/NotTaggedWith from TWX Help documentation and my queries still did not work.

 

This helped me a lot!

 

Tomas

Hi @TomasCharvat 

 

There is a ticket already opened with R&D to investigate why TaggedWith query parameter does not give the expected result. I will update here once I get a response on the ticket. 

 

Regards,

Sachin

Announcements


Top Tags