The Manage indexes setting for a hosted feature layer (item) allows you to manage the field and spatial indexes for a feature layer in a feature service. Creating indexes can greatly improve the response time of queries such as searches and filters.
What are indexes?
ArcGIS uses indexes to quickly locate data. Field indexes, also known as attribute indexes, are used to locate features that match an attribute query.
An additional type of field index is a full-text field index. A full-text index works on fields that contain strings with multiple words or terms. The index tokenizes the string into smaller units such as individual words or terms to improve the overall search performance.
Spatial indexes are used to locate features that match a spatial query. Indexes can decrease the time it takes for queries, such as searches or filters, to find the data requested. Attribute indexes can be created for single or multiple fields. They can be unique and can be created in ascending or descending order. Spatial indexes are used to locate features that match a spatial query.
How to manage index settings
The steps to manage the index settings are:
-
Sign in to your portal:
- ArcGIS Location Platform: Go to https://location.arcgis.com > My portal.
- ArcGIS Online: Go to https://www.arcgis.com/home/signin.html.
- ArcGIS Enterprise: Go to your portal URL. Learn more at ArcGIS Enterprise > Use > Get started > Access.
- Find the item.
- Use the item page to change the index settings.
Code examples
You can use data management tools to manage the index settings of a hosted feature layer (item) or you can use the ArcGIS REST APIs. The following examples illustrate how to programmatically get the properties, add an index, and rebuild the index of a hosted feature layer (item).
Get current index properties
This example uses a Feature Service URL to return the indexes of a feature layer.
Request
POST https://{host}/{organizationId}/arcgis/rest/services/{service_name}/FeatureServer/layers HTTP/1.1
&f=json
&token={access_token}
Response
"indexes": [
{
"name": "Shape__Area_Index",
"fields": "Shape__Area",
"isAscending": true,
"isUnique": false,
"description": ""
},
{
"name": "Shape__Length_Index",
"fields": "Shape__Length",
"isAscending": true,
"isUnique": false,
"description": ""
},
{
"name": "PK__PARKS_AN__C1BEA5A24C987E12",
"fields": "FID",
"isAscending": true,
"isUnique": true,
"description": "clustered, unique, primary key"
},
{
"name": "user_56805.{layer_name}_Shape_sidx",
"fields": "Shape",
"isAscending": false,
"isUnique": false,
"description": "Shape Index"
}
],
Set a new attribute index
This example uses the add
admin operation to add a new attribute index.
Request
POST https://{host}/{organizationId}/arcgis/rest/admin/services/{service_name}/FeatureServer/{layer_id}/addToDefinition HTTP/1.1
f=json
&token={access_token}
&addToDefinition: {
"indexes":[{
"name":"{index_name}",
"fields":"{field_name1}, {field_name2} ...",
"isUnique": false,
"isAscending": false,
"description": "{index_description}"
}
]}
Response
{
"success":true
}
Set a new full text index
This example uses the add
admin operation to add a full text attribute index.
Request
POST https://{host}/{organizationId}/arcgis/rest/admin/services/{service_name}/FeatureServer/{layer_id}/addToDefinition HTTP/1.1
f=json
&token={access_token}
&addToDefinition: {
"indexes":[{
"name":"{index_name}",
"fields":"{field_name1}, {field_name2} ...",
"indexType": "FullText",
"description": "{index_description}"
}
]}
Response
{
"success":true
}
Rebuild the spatial index
This example uses the update
admin operation to rebuild the spatial index.
Request
POST https://{host}/{organizationId}/arcgis/rest/admin/services/{service_name}/FeatureServer/{layerIdAr}/updateDefinition HTTP/1.1
f=json
&token={access_token}
&updateDefinition: {{
"indexes":[{
"name":"{existing_spatial_index_name}",
"fields":"Shape"
}
]}}
Response
{
"success":true
}
Tutorials
Import data to create a feature layer
Use data management tools to import files and create a feature layer in a feature service.
Define a new feature layer
Use data management tools to define and create a new empty feature layer in a feature service.
Manage a feature layer
Use a hosted feature layer item to set the properties and settings of a feature layer in a feature service.
Create a vector tile service
Use data management tools to create a new vector tile service from a feature service.
Create a map tile service
Use ArcGIS Online or scripting APIs to publish a map tile service.
Workflows
Create a feature service for an app
Learn how to import parcel data, create and style a feature layer, and then access the features in an app.
Create a feature layer view for an editor app
Learn how to import parcel data, create and style a feature layer view, and then access the features in an editing app.
Create a vector tile service for an app
Learn how to import parcel data, style a feature layer, and then create a vector tile service for an app.
Create a map tile service for an app
Learn how to import contour data, style a feature layer, and create a map tile service for an app.
Services
Feature service
Add, update, delete, and query feature data.
Vector tile service
Store and access vector tile data.
Map tile service
Store and access map tile data.
Image service
Store and access imagery and raster data.
API support
Use data management tools or Client APIs to create, manage, and access data services. The table below outlines the level of support for each API.
- 1. Use portal class and direct REST API requests
- 2. Access via ArcGIS REST JS
- 3. Requires manually setting styles for renderers