Select to view content in your preferred language

gis.content.search returns null

1017
4
Jump to solution
06-30-2021 05:20 AM
Labels (1)
HamzaM
by
New Contributor III

I am trying to search for a certain layer but it returns null this is the code i am using, i even tried outside_org= True but it still didn't work.

content.search.PNG

@JayantaPoddar @DanPatterson @DavidPike @jcarlson @DanLee @JoshuaBixby @Scott_Harris @TomBole 

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
jcarlson
MVP Esteemed Contributor

The REST documentation is a good place to look. Here's the page for items and item types for reference. Is that what you're asking?

If you want to get more information about the content in your portal, you can try something like this:

[f'{i.id}  |  {i.title[:32]:32}  |  {i.type}' for i in gis.content.search('', max_items=-1)]

This will return a "table" of items as text. If you identify the desired item in the list, you can then use

gis.content.get('some-itemID')

to get that item specifically.

To get a true table, you can also use the advanced_search function combined with the pandas module.

import pandas as pd

pd.DataFrame(gis.content.advanced_search('omaha', max_items=-1, as_dict=True)['results'])

 

This returns a DataFrame of the items and all of their details. The DataFrame itself can interacted with further to filter, sort, etc.

jcarlson_0-1625061965470.png

 

 

- Josh Carlson
Kendall County GIS

View solution in original post

0 Kudos
4 Replies
jcarlson
MVP Esteemed Contributor

Can you try searching without specifying item_type? Also, does searching for other items return anything? Or a search for an empty string?

You've posted in the ArcGIS Pro Community; are you doing this in a Notebook in Pro?

It's hard to know if it's simply that your search is too specific, or if something else is going on.

PS - Don't forget about the "code sample" button on here! Helps make code-based questions more readable.

jcarlson_0-1625057595306.png

 

- Josh Carlson
Kendall County GIS
HamzaM
by
New Contributor III

My search was too specific when i removed the item type it gave me results but not exactly what i am looking for, is there is a way to know more about all available content.

0 Kudos
jcarlson
MVP Esteemed Contributor

The REST documentation is a good place to look. Here's the page for items and item types for reference. Is that what you're asking?

If you want to get more information about the content in your portal, you can try something like this:

[f'{i.id}  |  {i.title[:32]:32}  |  {i.type}' for i in gis.content.search('', max_items=-1)]

This will return a "table" of items as text. If you identify the desired item in the list, you can then use

gis.content.get('some-itemID')

to get that item specifically.

To get a true table, you can also use the advanced_search function combined with the pandas module.

import pandas as pd

pd.DataFrame(gis.content.advanced_search('omaha', max_items=-1, as_dict=True)['results'])

 

This returns a DataFrame of the items and all of their details. The DataFrame itself can interacted with further to filter, sort, etc.

jcarlson_0-1625061965470.png

 

 

- Josh Carlson
Kendall County GIS
0 Kudos
HamzaM
by
New Contributor III

Yes, that's exactly what i was asking for, thanks a lot for your help and effort. 

0 Kudos