Roger Palmen

Pi Web API Search: why no WebIDs included of attributes?

Discussion created by Roger Palmen on Nov 9, 2014
Latest reply on Nov 11, 2014 by Roger Palmen

I'm looking for a way to use the PI Web API to build a (web) Portal. For that portal, one of the types of things that are needed is one KPI for each Asset. Assets, about 400 of them, are down 3 levels from the AF root.

 

I expected to resolve this using a query like this:

 
https://hostname/piwebapi/search/query?q=attributename:"KPI"&fields=attributes;webid;paths;name

 But the unexpected return is that i get a list of all Elements that contain an attribute containing "KPI", all attributes of all those elements, and the WebID of the Element. Not only i now get hundreds of attributes which i did not ask for, i also don't get the WebID of the attributes! So i still need to make 400 calls to request the WebIDs of attribute of the elements. I'd expected a similar return as the GET elements/{webId}/attributes call, which does include the WebIDs of the attributes.

 

So my basic questions: If the search allows searching for attributes, why not return the WebID's of the attributes?

 

Some other observations:

  • why not restrict to the queried attributenames? It's now not "search" but "elementsearch"
  • why do i get all attributes of the attributes and not only the requested fields?
  • why are different names used in different sections of the query? E.g. "afelementtemplate" in the q section, but "template" in the fields section
  • the documentation is missing a list of fields to use in each section (q / fields0. It's now just the fields in the help? Or guesswork?
  • documentation is a bit sparse on the search topic...

So the only option i see: is to wait for the ODATA supporting batch calls, or bulk calls support in general. The only way to get WebIDs of attributes is by using the GET attributes call, e.g on path or getting all attributes for the element.

Outcomes