zj_zou

Search for ArcGIS Online feature services or map services

Discussion created by zj_zou on Nov 20, 2013
I am using Portal.queryItems method trying to search for all feature services or map services owned by ESRI or from ArcGIS Online. Here is my code snippet. However, the items returned are not only the feature services or map services, but also map document, feature data, etc. How can I build the query string so that only feature services or map services will be returned.

Thanks in advance.

queryPortal: function (portalUser) {
    var portal = new Portal.Portal("https://www.arcgis.com/").signIn().then(function (portalUser) {
        var q_string = "(type: \"Feature Service\" OR \"Map Service\")";

        // if query items under "My Content"
        switch (selScope.value) {
        case "esri":
            q_string += " AND owner: esri";
        default:
            break;
        }

        // query by key word
        if (txtSearch.value) {
            q_string = (me.txtSearch.value.replace(/\s/g, "")) + " " + q_string;
        }

        var queryParams = {
            q: q_string,
            sortField: me.selScope.value === "arconline" ? "numViews" : "title", //  title | created | type | owner | avgRating | numRatings | numComments | numViews
            sortOrder: "asc", // "asc" | "desc"
            num: 100 // maximum number of items returned
        };

        portalUser.portal.queryItems(queryParams).then(createGallery);
    }).otherwise(function (error) {
        console.log("Error occurred while signing in: %s", error.message);
    });
}

Outcomes