Select to view content in your preferred language

REST.api Query

571
1
Jump to solution
02-12-2020 04:56 AM
CliveSwan
Occasional Contributor II

Greetings,

I have a query, using Python that returns all the Map Image layers.

I am trying to filter the query:

a) to filter out owner: esri_livingatlas

b) to filter out title: USA

If I use != or NOT  for owner, to filter. I get an error??

I can only use two parameters in the Query??

Thanks,

Clive

The code:

source = GIS(source_portal, source_admin, source_admin_password, verify_cert=False)
print("LOGGED INTO SOURCE")
title = "*"
owner != "esri*"
content = source.content.search("title:" + title, item_type="Map Image Layer", max_items=500)
print("OUTPUT")
for item in content:
    if 'title:' != '*USA*':
        print(item)
The output:
START
LOGGED INTO SOURCE
OUTPUT
<Item title:"National Weather Service Wind Forecast" type:Map Image Layer owner:esri_livingatlas> <Item title:"USA Weather Warnings and Watches" type:Map Image Layer owner:esri_livingatlas> <Item title:"National Weather Service Wind Gust Forecast" type:Map Image Layer owner:esri_livingatlas> <Item title:"USA Soil Map Units 2014 (Mature Support)" type:Map Image Layer owner:esri_livingatlas> <Item title:"2016 USA Organic Food Consumption" type:Map Image Layer owner:esri_livingatlas> <Item title:"2017 USA Diabetes Medication Users (Non-Insulin)" type:Map Image Layer owner:esri_livingatlas> <Item title:"2016 USA 401(k) Retirement Plans" type:Map Image Layer owner:esri_livingatlas> <Item title:"2017 USA Diabetes Medication Users (Insulin)" type:Map Image Layer owner:esri_livingatlas> <Item title:"USA USFS Lands (Mature Support)" type:Map Image Layer owner:esri_livingatlas> <Item title:"2016 USA Clothing/Accessory Store Market Opportunity" type:Map Image Layer owner:esri_livingatlas> <Item title:"2017 USA 401(k) Retirement Plans" type:Map Image Layer owner:esri_livingatlas> <Item title:"USA Soils Map Units" type:Map Image Layer owner:esri_livingatlas> <Item title:"2017 USA Transportation Fuel Spending" type:Map Image Layer owner:esri_livingatlas> <Item title:"2017 USA Child Care Spending" type:Map Image Layer owner:esri_livingatlas> <Item title:"2016 USA Online Banking" type:Map Image Layer owner:esri_livingatlas> <Item title:"USA Storm Reports" type:Map Image Layer owner:esri_livingatlas> <Item title:"USA Hazardous Waste Sites" type:Map Image Layer owner:esri_livingatlas> <Item title:"2017 USA Water and Public Services Spending" type:Map Image Layer owner:esri_livingatlas> <Item title:"USA NPS Lands (Mature Support)" type:Map Image Layer owner:esri_livingatlas> <Item title:"USA Wetlands 2015" type:Map Image Layer owner:esri_livingatlas> <Item title:"2017 USA Food Service Market Opportunity" type:Map Image Layer owner:esri_livingatlas> <Item title:"2017 USA Per Capita Income" type:Map Image Layer owner:esri_livingatlas> <Item title:"Elevation Coverage Map" type:Map Image Layer owner:esri_livingatlas>
0 Kudos
1 Solution

Accepted Solutions
CliveSwan
Occasional Contributor II

I placed the NOT in the variable, this worked..

It excluded all the esri_ layers

owner = "* NOT esri"
#content = source.content.search("title:" + title, item_type="Map Image Layer", max_items=500)
content = source.content.search("Owner:" + owner, item_type="Map Image Layer", max_items=500)
print("OUTPUT")
for item in content:
    print(item)

View solution in original post

0 Kudos
1 Reply
CliveSwan
Occasional Contributor II

I placed the NOT in the variable, this worked..

It excluded all the esri_ layers

owner = "* NOT esri"
#content = source.content.search("title:" + title, item_type="Map Image Layer", max_items=500)
content = source.content.search("Owner:" + owner, item_type="Map Image Layer", max_items=500)
print("OUTPUT")
for item in content:
    print(item)
0 Kudos