HOW TO

Create a full-text field index in ArcGIS Online or ArcGIS Enterprise using ArcGIS API for Python

Last Published: April 22, 2025

Summary

When searching for data in ArcGIS Online or ArcGIS Enterprise, field indexes are used to locate features that match the query. An additional type of field index is a full-text field index that contains strings with multiple words or terms. A full-text field index tokenizes the string into smaller units such as individual words or terms to improve the overall search performance. Refer to Portal and data services guide: Manage field and spatial indexes for more information. The index on the field can be set to full-text through the ArcGIS API definition and the process can be optimized using ArcGIS API for Python, for example when bulk edits are required or the item IDs are readily available without opening ArcGIS Online or ArcGIS Enterprise. This article provides the workflow. The script works in a stand-alone .py file or ArcGIS Notebook.

Procedure

  1. Import the necessary modules.
from arcgis.gis import GIS
from arcgis.features import FeatureLayer, Table, FeatureLayerCollection
  1. Specify the credentials and connect to the organization account.
  • ArcGIS Online
gis = GIS("www.arcgis.com", "<username>", "<password>")
  • ArcGIS Notebook
gis = GIS("home")
  • ArcGIS Enterprise
gis = GIS("https://<machine>.<domain>.com/<web_adaptor_name>", "<username>", "<password>", verify_cert=False)
  1. Specify the layer.
layerURL = "<layer_URL>"

layer = FeatureLayer(layerURL, gis)
  1. Create the definition dictionary and add the definition to the layer using the add_to_definition() function.
definition_json = {
	"indexes":[{
		"name":"<index_name>",
		"indexType":"FullText",
		"fields":"<field_name>",
		"description":"<description>"
	}]
}

res = layer.manager.add_to_definition(definition_json)
res

The following is a sample of the working script for ArcGIS Enterprise:

from arcgis.gis import GIS
from arcgis.features import FeatureLayer, FeatureLayerCollection

gis = GIS("https://machine.esri.com/arcgis", "username123", "password123", verify_cert=False)

layerURL = "https://services9.arcgis.com/Aas9879698ASFJB/arcgis/rest/services/TestPoint/FeatureServer/0"

layer = FeatureLayer(layerURL, gis)

definition_json = {
	"indexes":[{
		"name":"TestIndex",
		"indexType":"FullText",
		"fields":"TestField",
		"description":"This is a test index"
	}]
}

res = layer.manager.add_to_definition(definition_json)
res

Article ID: 000034169

Software:
  • ArcGIS Online
  • ArcGIS API for Python
  • ArcGIS Enterprise

Receive notifications and find solutions for new or common issues

Get summarized answers and video solutions from our new AI chatbot.

Download the Esri Support App

Related Information

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options