0

I am trying to automate the rebuild of file geodatabase indexes using ArcPy v10.6, but I encounter an ERROR 000837 The workspace is not the correct workspace type.

Question: If arcpy.RebuildIndexes_management() works only with Enterprise geodatabases, then how to rebuild indexes in file geodatabases?

import arcpy, os

workspace = "C:/tmp/myDatabase.gdb"
fc = "MyFeatureClass"
arcpy.Exists(workspace)
>>>True
arcpy.Exists(os.path.join(workspace, fc))
>>>True

arcpy.RebuildIndexes_management(workspace, "NO_SYSTEM", [fc], "ALL")
>>>ERROR 000837 The workspace is not the correct workspace type

.

2

That method cannot be used on a file geodatabase, from the tool help document, see usage statement below:

Data must be from a database or an enterprise, workgroup, or desktop geodatabase. This tool does not work with file or personal geodatabases.

To add an index to an existing feature class within a geodatabase you may use the Add Attribute Index or Add Spatial Index method:

  • I can't accept your post, because it does not really answer my question – Below the Radar Dec 4 '19 at 20:00
  • 2
    @BelowtheRadar how does this not answer your question? They explain why that tool does not work ( something easily solved if the help file had been researched) and they provide a solution, the add attribute tool. Suggest you explore the section of the help file about the index tools? – Hornbydd Dec 4 '19 at 21:30
  • @Hornbydd because I am asking what is the proper way to rebuild indexes with arcpy inside file geodatabase, not why it's not working with arcpy.RebuildIndexes_management() – Below the Radar Dec 4 '19 at 21:33
  • 2
    The answer above is the only way to build an attribute index for a file geodatabase. – Hornbydd Dec 4 '19 at 21:36
  • I want to rebuild existing indexes, so the answer should be something like, get the indexes infos from the featureClass, drop those indexes and create the indexes again – Below the Radar Dec 4 '19 at 21:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.