Create a Vector Search Index in Quick Mode

  • Capella Operational
  • how-to
    +
    Use Quick Mode to create a Vector Search index in Couchbase Capella.

    Quick Mode works best when you need to create a basic Search index to start testing and prototyping with the Search Service. You must use Advanced Mode to have greater control over how the Search Service returns such results, such as changing your analyzer.

    For more information about how to create a Search index in Advanced Mode, see Create a Basic Search Index in Advanced Mode.

    Vector Search indexes can include all the same features and settings as a Search index. For more information about Search indexes, see the Search documentation.

    You must create a Vector Search index before you can run a search that supports vector comparisons.

    Prerequisites

    • You have the Search Service enabled on a node in your cluster. For more information about how to change Services on your cluster, see Modify a Paid Cluster.

    • You have a bucket with scopes and collections in your cluster. For more information, see Manage Buckets.

    • You have documents in a keyspace inside your bucket that contain vector embeddings. Embeddings can be an array of floats or a base64 encoded string.

      You can import a sample dataset to use with the procedure or examples on this page.

      Go to Data Tools  Import from your cluster and import the vector-sample sample data.

    • You have logged in to the Couchbase Capella UI.

    Procedure

    To create a Vector Search index with Quick Mode in Capella:

    1. On the Operational Clusters page, select the cluster where you want to create a Search index.

    2. Go to Data Tools  Search.

    3. Click Create Search Index.

      By default, Quick Mode should be on.

    4. In the Index Name field, enter a name for the Vector Search index.

      Your index name must start with an alphabetic character (a-z or A-Z). It can only contain alphanumeric characters (a-z, A-Z, or 0-9), hyphens (-), or underscores (_).

      For Couchbase Server version 7.6 and later, your index name must be unique inside your selected bucket and scope. You cannot have 2 indexes with the same name inside the same bucket and scope.

    5. Under Type Mappings, in the Bucket list, select the bucket that contains the documents you want to include in your index.

    6. In the Scope list, select the scope that contains these documents.

    7. Expand the collection that contains these documents.

    8. In your document schema, select the child field that contains your vector embeddings.

    9. Configure the options for the child field as follows:

      1. In the Type list, select one of the following:

        1. If your child field contains vector embeddings as an array, click vector.

          Vector embeddings formatted as arrays appear as {field-name} [ number ] in the Capella Quick Mode editor.

        2. (Couchbase Server version 7.6.2 or later) If your child field contains vector embeddings formatted as a base64 encoded string, click vector_base64.

          Vector embeddings formatted as base64 strings appear as {field-name} [ string ] in the Capella Quick Mode editor.

      2. In the Dimension field, check that the value matches the total number of elements in your vector embeddings array.

        The Search Service supports arrays up to 2048 elements. Capella automatically fills in the dimension value for your selected child field when you choose the vector or vector_base64 type.

      3. In the Similarity metric list, choose the method to use to calculate the similarity between search term and Search index vectors.

        For more information, see Quick Field Type Mapping Options.

      4. In the Optimized for list, choose whether the Search Service should optimize Search queries for accuracy (recall) or speed (latency).

        For more information, see Quick Field Type Mapping Options.

      5. Select Index.

    10. Click Submit.

    11. (Optional) Add additional collections or child field type mappings to your index.

      For example, you could add the text field that you used to generate your vector embeddings.

    12. Click Create Index.

    Example: Creating a Vector Search Index for Vector Search Query Examples

    If you want to use the sample dataset for the examples in Run a Vector Search with the Capella UI and Run a Vector Search with a Couchbase SDK, then you can import the following Search index definition into Capella UI:

    {
        "name": "color-test",
        "type": "fulltext-index",
        "params": {
         "doc_config": {
          "docid_prefix_delim": "",
          "docid_regexp": "",
          "mode": "scope.collection.type_field",
          "type_field": "type"
         },
         "mapping": {
          "default_analyzer": "standard",
          "default_datetime_parser": "dateTimeOptional",
          "default_field": "_all",
          "default_mapping": {
           "dynamic": true,
           "enabled": false
          },
          "default_type": "_default",
          "docvalues_dynamic": false,
          "index_dynamic": true,
          "store_dynamic": false,
          "type_field": "_type",
          "types": {
           "color.rgb": {
            "dynamic": false,
            "enabled": true,
            "properties": {
             "description": {
              "enabled": true,
              "dynamic": false,
              "fields": [
               {
                "name": "description",
                "type": "text",
                "store": true,
                "index": true,
                "include_term_vectors": true,
                "include_in_all": false,
                "docvalues": true
               }
              ]
             },
             "brightness": {
              "enabled": true,
              "dynamic": false,
              "fields": [
               {
                "docvalues": true,
                "index": true,
                "name": "brightness",
                "store": true,
                "type": "number"
               }
              ]
             },
             "color": {
              "enabled": true,
              "dynamic": false,
              "fields": [
               {
                "docvalues": true,
                "include_term_vectors": true,
                "index": true,
                "name": "color",
                "store": true,
                "type": "text"
               }
              ]
             },
             "colorvect_l2": {
              "enabled": true,
              "dynamic": false,
              "fields": [
               {
                "dims": 3,
                "index": true,
                "name": "colorvect_l2",
                "similarity": "l2_norm",
                "type": "vector",
                "vector_index_optimized_for": "recall"
               }
              ]
             },
             "embedding_vector_dot": {
              "enabled": true,
              "dynamic": false,
              "fields": [
               {
                "dims": 1536,
                "index": true,
                "name": "embedding_vector_dot",
                "similarity": "dot_product",
                "type": "vector",
                "vector_index_optimized_for": "recall"
               }
              ]
             }
            }
           }
          }
         },
         "store": {
          "indexType": "scorch",
          "segmentVersion": 16
         }
        },
        "sourceType": "gocbcore",
        "sourceName": "vector-sample",
        "sourceParams": {},
        "planParams": {
         "maxPartitionsPerPIndex": 1024,
         "indexPartitions": 1,
         "numReplicas": 0
        },
        "uuid": "42676f35cc30b84a"
       }
    Make sure you imported the sample dataset with the recommended settings.

    This Vector Search index has a type mapping for a color.rgb collection and includes the following fields:

    • The brightness number field, which is included in search results and supports sorting and faceting.

    • The color string and description string fields, which are included in search results, support highlighting, phrase matching, and sorting and faceting.

    • The colorvect_l2 [ number ] field, which has a Dimension of 3 and uses the l2_norm Similarity Metric.

    • The embedding_vector_dot [ number ] field, which has a dimension of 1536 and uses the dot_product Similarity Metric.

    Next Steps

    This basic Vector Search index includes the vector embeddings from the child field you specified in your type mapping. If you chose to add additional child fields and enabled Include in search results, the Search Service can also return data from those fields when you run a Vector Search query.

    For example, if you used the Vector Search sample data, you might want to add another child field for the color string field to your Vector Search index, to return color names with your Search query. For more information about how to add additional child fields to your index, see Create a Search Index in Quick Mode or Create a Child Field in Advanced Mode.

    You can customize your Vector Search index like any other Search index to add additional data and improve search results. For more information about how to customize an index, see Search Index Features.

    Some Search index features are only available in Advanced Mode. If you edit your Search index in Advanced Mode, you cannot make any additional edits in Quick Mode without losing all Advanced Mode settings.

    For more information about how to run a search against a Vector Search index, see Run a Vector Search with the Capella UI.