Skip to content
Start here

Create Metadata Index

client.Vectorize.Indexes.MetadataIndex.New(ctx, indexName, params) (*IndexMetadataIndexNewResponse, error)
POST/accounts/{account_id}/vectorize/v2/indexes/{index_name}/metadata_index/create

Enable metadata filtering based on metadata property. Limited to 10 properties.

Security
API Token

The preferred authorization scheme for interacting with the Cloudflare API. Create a token.

Example:Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY
API Email + API Key

The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.

Example:X-Auth-Email: user@example.com

The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.

Example:X-Auth-Key: 144c9defac04969c7bfad8efaa8ea194
Accepted Permissions (at least one required)
Vectorize Write
ParametersExpand Collapse
indexName string
params IndexMetadataIndexNewParams
AccountID param.Field[string]

Path param: Identifier

maxLength32

Body param: Specifies the type of metadata property to index.

const IndexMetadataIndexNewParamsIndexTypeString IndexMetadataIndexNewParamsIndexType = "string"
const IndexMetadataIndexNewParamsIndexTypeNumber IndexMetadataIndexNewParamsIndexType = "number"
const IndexMetadataIndexNewParamsIndexTypeBoolean IndexMetadataIndexNewParamsIndexType = "boolean"
PropertyName param.Field[string]

Body param: Specifies the metadata property to index.

ReturnsExpand Collapse
type IndexMetadataIndexNewResponse struct{…}
MutationID stringOptional

The unique identifier for the async mutation operation containing the changeset.

maxLength36

Create Metadata Index

package main

import (
  "context"
  "fmt"

  "github.com/stainless-sdks/cloudflare-go"
  "github.com/stainless-sdks/cloudflare-go/option"
  "github.com/stainless-sdks/cloudflare-go/vectorize"
)

func main() {
  client := cloudflare.NewClient(
    option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
  )
  metadataIndex, err := client.Vectorize.Indexes.MetadataIndex.New(
    context.TODO(),
    "example-index",
    vectorize.IndexMetadataIndexNewParams{
      AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
      IndexType: cloudflare.F(vectorize.IndexMetadataIndexNewParamsIndexTypeString),
      PropertyName: cloudflare.F("random_metadata_property"),
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", metadataIndex.MutationID)
}
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "result": {
    "mutationId": "0000aaaa-11bb-22cc-33dd-444444eeeeee"
  },
  "success": true
}
Returns Examples
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "result": {
    "mutationId": "0000aaaa-11bb-22cc-33dd-444444eeeeee"
  },
  "success": true
}