HOW TO
When searching for data in ArcGIS Online or Portal for ArcGIS, 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 Portal for ArcGIS. This article provides the workflow. The script works in a stand-alone .py file or ArcGIS Notebook.
from arcgis.gis import GIS from arcgis.features import FeatureLayer, Table, FeatureLayerCollection
gis = GIS("www.arcgis.com", "<username>", "<password>")
gis = GIS("home")
gis = GIS("https://<machine>.<domain>.com/<web_adaptor_name>", "<username>", "<password>", verify_cert=False)
layerURL = "<layer_URL>" layer = FeatureLayer(layerURL, gis)
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 Portal for ArcGIS:
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
Get help from ArcGIS experts
Download the Esri Support App