Skip to main content
1-Visitor
July 12, 2021
Question

Getting total No of Things count, thing name starts with "Test-"

  • July 12, 2021
  • 1 reply
  • 1881 views

Hi,

 

I would like to get total no of things as count, in which thing name starts with "Test-". As these kind of things in platform are very huge like more or less to 100000 (more than lakhs and those are remote things)., like to know getting count as result directly from api instead of  infotable aggregate functions...

 

Kindly let me know, if any api/service available to get the count directly with out infotable.

 

Thanks

Gopi

1 reply

16-Pearl
July 14, 2021

Hi,

 

As far as I know, there's no such API readily available that fulfills your exact requirement.

I would create a custom service like below combining predefined services SpotlightSearch and getRowCount.

Then you can send POST request to http://host:port/Thingworx/Things/<ThingName>/Services/<ServiceName>

to call the custom thing service.

 

***************************************************
let params = {
    searchExpression: "Test-*" /* STRING */,
    types: {"items" : ["Thing"]} /* JSON */,

    searchDescriptions: false,

    aspects: { "isSystemObject":"false" }
};


let result = Resources["SearchFunctions"].SpotlightSearch(params).getRowCount();

***************************************************

1-Visitor
July 14, 2021

Hi Tony,

 

Thanks for your response.

 

If not provided the maxItems to SpotlightSearch(), is it providing all things which are matching.. All these similar things are more than 100000...  What is the defaultValue of maxItems, if not provided.

 

Thanks

Gopi

16-Pearl
July 14, 2021

Hi Gopi,

 

That's a good question...

 

I haven't found any detailed info on maxItems in any documentation.

My assumption was if maxItems is not specified, it should return all things that match the SpotlightSearch criteria.

But you can test this by comparing the row number returned 1) when maxItems is specified to a large enough number and 2) when leaving out maxItems

 

There's a similar input called maxSearchItems.

I found "the default value of maxSearchItems variable is 100000" in an internal page. Please also test this variable as well since you have more than 100000 things in your system.

  • maxSearchItems – The maximum number of items to search
  • maxItems – The maximum number of items to return in the result

Thanks,

Tony