Skip to main content
12-Amethyst
September 7, 2020
Question

Do a stream query with tags filter

  • September 7, 2020
  • 1 reply
  • 1908 views

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.

1 reply

5-Regular Member
September 10, 2020

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"
}
]
}
};

 

14-Alexandrite
March 8, 2021

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

16-Pearl
March 8, 2021

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