Use namespaces
Pinecone allows you to partition the records in an index into namespaces. Queries and other operations are then limited to one namespace, so different requests can search different subsets of your index.
For example, you might want to define a namespace for indexing articles by content, and another for indexing articles by title. For a complete example, see our Namespaces example notebook.
Every index is made up of one or more namespaces. Every record exists in exactly one namespace.
Namespaces are uniquely identified by a namespace name, which almost all operations accept as a parameter to limit their work to the specified namespace. When you don’t specify a namespace name for an operation, Pinecone uses the default namespace name of ""
(the empty string).
Creating a namespace
Namespaces are created automatically the first time they are used to upsert records. If the namespace doesn’t exist, it is created implicitly.
For example, the code below creates theexample-namespace1
and example-namespace2
namespaces, if they don’t already exist:
Querying a namespace
Each query is limited to a single namespace within an index. To target a namespace, pass the namespace
parameter. To query the default namespace, pass ""
or omit the namespace
parameter.
For example, the queries below search the example-namespace1
and example-namespace2
namespaces:
Operations across all namespaces
All vector operations apply to a single namespace, with one exception:
The DescribeIndexStatistics
operation returns per-namespace statistics about the contents of all namespaces in an index. More details
Was this page helpful?