2023-06-18

Selective Metadata Indexing in Pinecone

Selective Metadata Indexing in Pinecone

By default, Pinecone automatically indexes all metadata. Indexing these metadata fields allows for more specific vector search filtering. However, if you choose to store metadata without indexing it, it's a memory-saving move. This approach is especially beneficial when dealing with a plethora of unique metadata entries, enabling more vectors to be accommodated in each pod.

Configuring Selective Metadata Indexing

When you create a new index, you can specify which metadata fields to index using the metadata_config parameter.

metadata_config = {
    "indexed": ["desired-metadata-field-name"]
}

By populating the indexed list with the required metadata field names, developers can explicitly instruct Pinecone which fields to index.

  • Python
python
metadata_config = {
    "indexed": ["metadata-field-name"]
}

pinecone.create_index("example-index", dimension=128,
                      metadata_config=metadata_config)
  • curl
bash
$ curl -i -X POST https://controller.YOUR_ENVIRONMENT.pinecone.io/databases \
  -H 'Api-Key: YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "name": "example-index",
    "dimension": 128,
    "metadata_config": {
      "indexed": ["metadata-field-name"]
    }
  }'

References

https://docs.pinecone.io/docs/manage-indexes#selective-metadata-indexing

Ryusei Kakujo

researchgatelinkedingithub

Focusing on data science for mobility

Bench Press 100kg!