Is there a way to search your Enterprise Portal for a hosted table using the content manager search()? I've tried a few different ways using the item_type= parameter, but I get nothing. And there is no obvious mention of tables in the Items and item types API help page?
table = gis.content.search(query="title:csvtest", item_type='table')
I've also tried these:
item_type='hosted table'
item_type='Table'
item_type='Table Layer'
They all give me this
[]
There is, however, a table in my content. I can find it with the required query parameter alone. The item type will come back as Table Layer, which, as you see above, I have tried.
table = gis.content.search(query="title:csvtest")
###result
<Item title:"csvtest" type:Table Layer owner:admin>
Solved! Go to Solution.
When you call Item.type on a table, you get 'Feature Service'. Specifying that in the item_type parameter will return table layers, too.
However, there does seem to be some separate attribute being stored somewhere that identifies the service as a table, but where? If you look at the service JSON, you'll see something like this:
{
...
"type" : "Feature Service",
"typeKeywords" : [
"ArcGIS Server",
"Data",
"Feature Access",
"Feature Service",
"Service",
"Table",
"Hosted Service"
],
...
}
Refer to the search reference page, and you'll see that 'typekeywords' is its own search parameter, and goes in the query string.
# This works
gis.content.search('table')
# This is more specific, and probably better
gis.content.search('typekeywords:table')
Both commands return:
[<Item title:"Join_Features_to_GISFIPSMG" type:Table Layer owner:carlsonj9>,
<Item title:"date test" type:Table Layer owner:carlsonj9>,
<Item title:"GISFIPSMG" type:Table Layer owner:carlsonj9>]
EDIT: It looks like the items and item types page does not reference tables in type or typekeyword, so you'd be forgiven for not being able to find this information. I've sent feedback for the page to get updated.
When you call Item.type on a table, you get 'Feature Service'. Specifying that in the item_type parameter will return table layers, too.
However, there does seem to be some separate attribute being stored somewhere that identifies the service as a table, but where? If you look at the service JSON, you'll see something like this:
{
...
"type" : "Feature Service",
"typeKeywords" : [
"ArcGIS Server",
"Data",
"Feature Access",
"Feature Service",
"Service",
"Table",
"Hosted Service"
],
...
}
Refer to the search reference page, and you'll see that 'typekeywords' is its own search parameter, and goes in the query string.
# This works
gis.content.search('table')
# This is more specific, and probably better
gis.content.search('typekeywords:table')
Both commands return:
[<Item title:"Join_Features_to_GISFIPSMG" type:Table Layer owner:carlsonj9>,
<Item title:"date test" type:Table Layer owner:carlsonj9>,
<Item title:"GISFIPSMG" type:Table Layer owner:carlsonj9>]
EDIT: It looks like the items and item types page does not reference tables in type or typekeyword, so you'd be forgiven for not being able to find this information. I've sent feedback for the page to get updated.
Josh,
Thanks for the reply. I was able to get back the table I was searching for:
table = gis.content.search("typekeywords:table")
table
#out[]: <Item title:"csvtest" type:Table Layer owner:admin
...
#this also worked
table = gis.content.search(query="typekeywords:table")
However, that also returns every other table owned by admin. There are seven.
I want to single out my table. And using the other parameters doesn't seem to do anything. For example, this will return all the tables under admin.
table = gis.content.search("typekeywords:table", sort_field='csvtest')
I've considered using an index number [0] to find the item, but that can be slippery as my colleagues also add content to the Portal with the admin sign-in. So, it might be [0] one day but not the next.
This isn't very encouraging:
"Care should be taken when using ArcGIS REST API search operations... The Portal uses a powerful search engine to index information and to allow full text searching on it. This search engine uses many different inputs to find the appropriate results and rank them. This often makes search 'fuzzy', making it ideal for human interaction, but not necessarily ideal for looking for specific records programmatically. Developers should avoid using search to find specific items (e.g. by title) as the results of these types of queries might change as the search engine evolves."
Ay caramba. I try to stick with "gis.content.get('itemid')" for that reason.
Owner is also a query string parameter.
gis.content.search('typekeywords:table owner:carlsonj9')