<?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: Listing only attribute indexes in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/listing-only-attribute-indexes/m-p/133270#M10388</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Your answer is quite helpful because I've realized that the spatial index for personal geodatabases is always Shape_index and the spatial index for file geodatabases is always FDO_SHAPE. Sometimes they are uppercase and sometimes lowercase, but that's all.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It's as simple as skipping those index names. Thanks! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Now I have a new problem related to the attribute indexes based on the OBJECTID field. I can't delete any attr. index based on that field. I'm getting an error message. &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In fact, I can't add an attribute index based on the OBJECTID field either. :((&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 21 Nov 2013 13:06:44 GMT</pubDate>
    <dc:creator>AleydisG__Pere</dc:creator>
    <dc:date>2013-11-21T13:06:44Z</dc:date>
    <item>
      <title>Listing only attribute indexes</title>
      <link>https://community.esri.com/t5/python-questions/listing-only-attribute-indexes/m-p/133268#M10386</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I need a script to check the attribute indexes of every feature class in a geodatabase, to delete or create the indexes to fit my needs.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've used the &lt;/SPAN&gt;&lt;STRONG&gt;ListIndexes&lt;/STRONG&gt;&lt;SPAN&gt; arcpy function but it lists not only attribute indexes but also spatial indexes. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there a way to list only attribute indexes?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy

fields =&amp;nbsp; "OBJECTID"
index_name =&amp;nbsp; "FDO_OBJECTID"
unique_vals = "UNIQUE"
order = "ASCENDING"
FSO_OID = False

try:

&amp;nbsp;&amp;nbsp;&amp;nbsp; gdb = arcpy.GetParameterAsText(0) 
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.env.workspace = gdb

&amp;nbsp;&amp;nbsp;&amp;nbsp; fdatasets = arcpy.ListDatasets()
&amp;nbsp;&amp;nbsp;&amp;nbsp; for fdataset in fdatasets:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("Feature dataset: " + fdataset)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage('-' * 40)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fcs = arcpy.ListFeatureClasses('','',fdataset)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for fc in fcs:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; indexes = arcpy.ListIndexes(fc) # ----&amp;gt; Lists both attribute and spatial indexes!!!
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for index in indexes:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (index.name &amp;lt;&amp;gt; index_name):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.RemoveIndex_management(fc, index.name)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FSO_OID = True
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if FSO_OID == False:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddIndex_management(fc, fields, index_name, unique_vals, order)

except:
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.GetMessages(2)&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Nov 2013 10:09:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/listing-only-attribute-indexes/m-p/133268#M10386</guid>
      <dc:creator>AleydisG__Pere</dc:creator>
      <dc:date>2013-11-21T10:09:52Z</dc:date>
    </item>
    <item>
      <title>Re: Listing only attribute indexes</title>
      <link>https://community.esri.com/t5/python-questions/listing-only-attribute-indexes/m-p/133269#M10387</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I need a script to check the attribute indexes of every feature class in a geodatabase, to delete or create the indexes to fit my needs.&lt;BR /&gt;&lt;BR /&gt;I've used the &lt;STRONG&gt;ListIndexes&lt;/STRONG&gt; arcpy function but it lists not only attribute indexes but also spatial indexes. &lt;BR /&gt;&lt;BR /&gt;Is there a way to list only attribute indexes?&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy

fields =&amp;nbsp; "OBJECTID"
index_name =&amp;nbsp; "FDO_OBJECTID"
unique_vals = "UNIQUE"
order = "ASCENDING"
FSO_OID = False

try:

&amp;nbsp;&amp;nbsp;&amp;nbsp; gdb = arcpy.GetParameterAsText(0) 
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.env.workspace = gdb

&amp;nbsp;&amp;nbsp;&amp;nbsp; fdatasets = arcpy.ListDatasets()
&amp;nbsp;&amp;nbsp;&amp;nbsp; for fdataset in fdatasets:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("Feature dataset: " + fdataset)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage('-' * 40)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fcs = arcpy.ListFeatureClasses('','',fdataset)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for fc in fcs:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; indexes = arcpy.ListIndexes(fc) &lt;STRONG&gt;# ----&amp;gt; Lists both attribute and spatial indexes!!!&lt;/STRONG&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for index in indexes:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (index.name &amp;lt;&amp;gt; index_name):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.RemoveIndex_management(fc, index.name)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FSO_OID = True
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if FSO_OID == False:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddIndex_management(fc, fields, index_name, unique_vals, order)

except:
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.GetMessages(2)&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What I don't know is if *all* spatial indexes have the word "Shape" in them.&amp;nbsp; If so, then you can just test for this string value in the index name:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
'skip over any index name with string Shape in it
if not "Shape" in index.name:
&amp;nbsp;&amp;nbsp; arcpy.RemoveIndex_management(fc, index.name)
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Or alternatively, can you just skip over the ObjectID field to check for attribute indexes?&amp;nbsp; (I am not sure if that is sufficient because I don't know if all spatial indexes are found on that field).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;

'describe each featureclass and build a list of indexes on each
for fc in fcs:
&amp;nbsp;&amp;nbsp; dsc = arcpy.Describe(fc)
&amp;nbsp;&amp;nbsp; listOfIndexes = [idx.name for idx in dsc.Indexes][1:]

&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I question the validity of simply skipping over the OID field as this.&amp;nbsp; When I look at the properties of a FeatureClass and see it's spatial index name "FDO_Shape", it also shows up in the listOfIndexes list when run.&amp;nbsp; So, it appears to not catch it by simply skipping over the OID.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Sorry for a non-direct answer, but maybe you can sort it out from here.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 07:28:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/listing-only-attribute-indexes/m-p/133269#M10387</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2021-12-11T07:28:37Z</dc:date>
    </item>
    <item>
      <title>Re: Listing only attribute indexes</title>
      <link>https://community.esri.com/t5/python-questions/listing-only-attribute-indexes/m-p/133270#M10388</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Your answer is quite helpful because I've realized that the spatial index for personal geodatabases is always Shape_index and the spatial index for file geodatabases is always FDO_SHAPE. Sometimes they are uppercase and sometimes lowercase, but that's all.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It's as simple as skipping those index names. Thanks! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Now I have a new problem related to the attribute indexes based on the OBJECTID field. I can't delete any attr. index based on that field. I'm getting an error message. &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In fact, I can't add an attribute index based on the OBJECTID field either. :((&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Nov 2013 13:06:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/listing-only-attribute-indexes/m-p/133270#M10388</guid>
      <dc:creator>AleydisG__Pere</dc:creator>
      <dc:date>2013-11-21T13:06:44Z</dc:date>
    </item>
    <item>
      <title>Re: Listing only attribute indexes</title>
      <link>https://community.esri.com/t5/python-questions/listing-only-attribute-indexes/m-p/133271#M10389</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Now I have a new problem related to the attribute indexes based on the OBJECTID field. I can't delete any attr. index based on that field. I'm getting an error message. &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;In fact, I can't add an attribute index based on the OBJECTID field either. :((&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Probably this is because the index already exists.&amp;nbsp; Try dropping it first... From &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#/Add_Attribute_Index/00170000005z000000/"&gt;http://resources.arcgis.com/en/help/main/10.1/index.html#/Add_Attribute_Index/00170000005z000000/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;If an index name already exists, it must be dropped before it can be updated.&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Nov 2013 16:46:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/listing-only-attribute-indexes/m-p/133271#M10389</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2013-11-21T16:46:40Z</dc:date>
    </item>
  </channel>
</rss>

