Using JS API to aggregate portal items

04-02-2020 07:35 AM
New Contributor III

I'm using ArcGIS JS 4.14 and querying AGOL for items under my organization. 

         portal.load().then(function() {
          var queryParams = new PortalQueryParams({
            query: 'owner:"' + portal.user.username +  '" orgid:' + + ' (type:("Web Map" OR "Web Mapping Application"))',
            sortField: "modified",
            sortOrder: "desc",
            num: 100,
            extent: view.extent

This works fine as it returns the portal items.

However I'm not interested in the individual items but rather on counts (aggregations) around tags and types, as actually supported by underlying REST API: Search—ArcGIS REST API: Users, groups, and content | ArcGIS for Developers 

So I'm really interested to doing something like this in the JS code:

        portal.load().then(function() {
          var queryParams = new PortalQueryParams({
            query: "owner:" + portal.user.username,
            countField: 'tags',
            countSize: 200,
            num: 0

Except, the PortalQueryParams does not seem to pass those properties down to the underlying dojo libraries..

PortalQueryParams | ArcGIS API for JavaScript 4.14 

Am I missing something or is this not supported by the current iteration of JS API?

Same thing is available in other APIs, like the ArcGIS for Python API.

At this point I'm left with hitting the REST endpoint directly by composing the search strings. Not great.

Any recommendations?

.. I wish Esri would open up access to the underlying Elasticsearch engine they use for Portal or AGOL. Current API is crippled in this respect.

Thanks in advance for any future replies.

0 Replies