PortalQueryParameters CanSearchPublic Not Working

1179
2
Jump to solution
03-19-2017 05:04 AM
ChadYoder1
Occasional Contributor II

Setting the CanSearchPublic flag for the PortalQueryParameters doesn't seem to have an impact on the results:

var queryString = "type:(\"web map\" NOT \"web mapping application\")";
var portalQuery = new PortalQueryParameters (queryString);
portalQuery.CanSearchPublic = false;
var maps = await arcgisPortal.FindItemsAsync (portalQuery);
ToastHelpers.ShowInfo ("Web Maps", maps.TotalResultsCount.ToString (), 3);
0 Kudos
1 Solution

Accepted Solutions
GregDeStigter
Esri Contributor

Your right - it's a bug. Setting the `CanSearchPublic` flag to `false` should restrict a query to only an organization's items. I've submitted an issue to get this fixed in an upcoming release.

In the meantime you can workaround this by providing an organization id in the query string.

var orgQuery = $"orgid:{_portal.PortalInfo.OrganizationId}";
var portalQuery = PortalQueryParameters.CreateForItemsOfType(PortalItemType.WebMap, orgQuery);
var maps = await _portal.FindItemsAsync(portalQuery);
Debug.WriteLine($"Web Maps: {maps.TotalResultsCount}");

View solution in original post

2 Replies
GregDeStigter
Esri Contributor

Your right - it's a bug. Setting the `CanSearchPublic` flag to `false` should restrict a query to only an organization's items. I've submitted an issue to get this fixed in an upcoming release.

In the meantime you can workaround this by providing an organization id in the query string.

var orgQuery = $"orgid:{_portal.PortalInfo.OrganizationId}";
var portalQuery = PortalQueryParameters.CreateForItemsOfType(PortalItemType.WebMap, orgQuery);
var maps = await _portal.FindItemsAsync(portalQuery);
Debug.WriteLine($"Web Maps: {maps.TotalResultsCount}");

View solution in original post

ChadYoder1
Occasional Contributor II

Excellent, that'll work for now.  Hadn't realized you could use the query text for the organization.

Thanks for the quick feedback, much appreciated.

0 Kudos