Create a Search Index
- concept
Create a Search index to get started with the Search Service in your database.
You can create a Search index with:
If you’re new to developing with the Search Service, create a Search index with the UI. You can copy the Search index definition JSON payload from the UI to create your index with the REST API, or Import a Search Index Definition with the Web Console. |
Creating a Search Index with the Web Console
To create a basic Search index, provide the following information:
-
The name of the index.
-
The bucket where you want to create the index.
Many of the examples in the Search Service documentation use the travel-sample
sample data bucket.
For more information about how to load this sample data on your own database, see Sample Buckets.
For indexes created with Couchbase Server version 7.6 and later, index names must be unique inside a bucket and scope. You cannot have 2 indexes with the same name inside the same bucket and scope on a Couchbase Server database running version 7.6. The Couchbase Server Web Console marks indexes as scoped or not scoped to a specific bucket and scope. Indexes created with a previous version of Couchbase Server are not scoped. To view the full, scoped name for an index, go to the Search tab and point to the Index Name. Use the scoped name with the Search Service REST API, for any endpoints that do not include the bucket and scope in their path. |
If you want to restrict the documents you add to an index, you can also:
-
Add child fields to add or remove document fields from the index.
After you create a Search index, the Search Service streams data from your chosen collection or collections, and any document mutations, into the index builder. Before your index finishes building, you can run a search and return partial results.
You can also customize a Search index to improve search results and performance. For more information about how you can customize a Search index with the Web Console, see Customize a Search Index with the Web Console.
Creating a Search Index with the Quick Editor
The Web Console also has a Quick Index editor.
You can use the Quick Index editor to create a Search index by selecting fields from a document from your database.
The Quick Index editor works best when you need to create a basic Search index to start testing and prototyping with the Search Service. If you want to have greater control over how the Search Service returns results, such as changing your analyzer, use the standard editor.
You can edit an index that you created with the Quick Index editor in the standard editor later. You cannot edit an index that you created with the standard editor in the Quick Index editor.
For more information about how to create an index with the Quick Index editor, see Create a Search Index with the Quick Editor.
Creating a Search Index with the REST API
You can create a Search index with the REST API through a JSON payload. Most properties in the JSON payload correspond to settings in the Web Console. You can also copy the Search index definition JSON payload from a Search index in the Web Console to use in a REST API call.
Use the scoped name for an index with the Search Service REST API for any endpoints that do not include the bucket and scope in their path.
For example, you must use |
For more information about how to use the REST API to create a Search index, see Create a Search Index with the REST API and curl/HTTP.
For more information about the available properties for a Search index, see Search Index JSON Properties.