<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Filtering Views from collection of hosted feature layers in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/filtering-views-from-collection-of-hosted-feature/m-p/1370561#M9534</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I don't see an elegant way to do this in the search.&lt;/P&gt;&lt;P&gt;I have not tested this but it looks like for each feature layer in your search results, you could retrieve the related items (&lt;A href="https://developers.arcgis.com/python/api-reference/arcgis.gis.toc.html#arcgis.gis.Item.related_items" target="_blank"&gt;https://developers.arcgis.com/python/api-reference/arcgis.gis.toc.html#arcgis.gis.Item.related_items&lt;/A&gt;) in the forward direction, using the Service2Data relationship type (you might need to play around with the parameters). If there aren't any related items, then it isn't a view.&lt;/P&gt;&lt;P&gt;Does that get you what you need?&lt;/P&gt;&lt;P&gt;Jill&lt;/P&gt;</description>
    <pubDate>Tue, 16 Jan 2024 16:56:40 GMT</pubDate>
    <dc:creator>JillianStanford</dc:creator>
    <dc:date>2024-01-16T16:56:40Z</dc:date>
    <item>
      <title>Filtering Views from collection of hosted feature layers</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/filtering-views-from-collection-of-hosted-feature/m-p/1370466#M9531</link>
      <description>&lt;P&gt;Greeting fellow travellers:&lt;/P&gt;&lt;P&gt;I am querying my portal for feature service types. By default it returns the hosted feature layer&amp;nbsp;&lt;STRONG&gt;and&lt;/STRONG&gt; the views on the hosted feature layer. I would like to do something with the hosted feature layers and ignore the hosted feature layer views. Code looks like this:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;    the_query = "type:Feature Service"
    some_content = gis.content.search(query=the_query, max_items=10000, outside_org=False)
    for a_layer in some_content:
        # do something if it's a hosted feature layer, ignore it if it's a view&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;How do I get just the layers and ignore the views?&lt;/P&gt;&lt;P&gt;Thanks in advance, please and thank you.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jan 2024 14:32:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/filtering-views-from-collection-of-hosted-feature/m-p/1370466#M9531</guid>
      <dc:creator>Dirk_Vandervoort</dc:creator>
      <dc:date>2024-01-16T14:32:39Z</dc:date>
    </item>
    <item>
      <title>Re: Filtering Views from collection of hosted feature layers</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/filtering-views-from-collection-of-hosted-feature/m-p/1370561#M9534</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I don't see an elegant way to do this in the search.&lt;/P&gt;&lt;P&gt;I have not tested this but it looks like for each feature layer in your search results, you could retrieve the related items (&lt;A href="https://developers.arcgis.com/python/api-reference/arcgis.gis.toc.html#arcgis.gis.Item.related_items" target="_blank"&gt;https://developers.arcgis.com/python/api-reference/arcgis.gis.toc.html#arcgis.gis.Item.related_items&lt;/A&gt;) in the forward direction, using the Service2Data relationship type (you might need to play around with the parameters). If there aren't any related items, then it isn't a view.&lt;/P&gt;&lt;P&gt;Does that get you what you need?&lt;/P&gt;&lt;P&gt;Jill&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jan 2024 16:56:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/filtering-views-from-collection-of-hosted-feature/m-p/1370561#M9534</guid>
      <dc:creator>JillianStanford</dc:creator>
      <dc:date>2024-01-16T16:56:40Z</dc:date>
    </item>
    <item>
      <title>Re: Filtering Views from collection of hosted feature layers</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/filtering-views-from-collection-of-hosted-feature/m-p/1371949#M9539</link>
      <description>&lt;P&gt;There are two ways you can do this. Both rely on typeKeywords. When you create a View, I believe a type keyword is automatically attached to it (this is true in the UI, at least).&lt;/P&gt;&lt;P&gt;You can do something like this with your query string to filter out views:&lt;/P&gt;&lt;PRE&gt;the_query = "NOT typekeywords:View Service AND owner:youruser"&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Or, in your loop you can use Item.typeKeywords to isolate views if you need to do further manipulations. The typeKeywords property for a view should be equal to a list like so:&lt;/P&gt;&lt;PRE&gt;['ArcGIS Server',
 'Data',
 'Feature Access',
 'Feature Service',
 'Service',
 'Singlelayer',
 'Hosted Service',
 'View Service']&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, you can do: if&amp;nbsp; "View Service" in item.typeKeywords do this or that.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jan 2024 21:34:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/filtering-views-from-collection-of-hosted-feature/m-p/1371949#M9539</guid>
      <dc:creator>EarlMedina</dc:creator>
      <dc:date>2024-01-18T21:34:51Z</dc:date>
    </item>
  </channel>
</rss>

