Pinecone Index

class pinecone.Index(name: str, **kwargs)

Pinecone Index.

Parameters
  • name (str) – name of Pinecone index.

  • **kwargs – See below

Keyword Arguments
  • batch_size (int) – the number of items to batch-process. Defaults to 100.

  • disable_progress_bar (bool) – whether to disable progress bar. Defaults to False.

  • grpc_config (dict) – See pinecone.grpc.GRPCClientConfig for grpc client related configurations.

close()

Closes the connection to the index.

delete(ids: Iterable[str], namespace: str = None, **kwargs) → Iterable[pinecone.index.DeleteResult]

Deletes items by their ids.

Parameters
  • ids (Iterable[str]) – ids of items

  • namespace (str, optional) – a partition in an index. Use default namespace when not specified.

  • **kwargs – See below

Keyword Arguments
  • batch_size (int) – overrides the number of items to batch-process.

  • disable_progress_bar (bool) – overrides whether to disable the progress bar

Returns

Acknowledgements of items deleted from the index.

Return type

Iterable[DeleteResult]

fetch(ids: Iterable[str], namespace: str = None, **kwargs) → Iterable[pinecone.index.FetchResult]

Fetches items by their ids.

Parameters
  • ids (Iterable[str]) – ids of items

  • namespace (str, optional) – a partition in an index. Use default namespace when not specified.

  • **kwargs – See below

Keyword Arguments
  • batch_size (int) – overrides the number of items to batch-process.

  • disable_progress_bar (bool) – overrides whether to disable the progress bar

Returns

id-vector pairs stored in the index.

Return type

Iterable[FetchResult]

info(namespace: str = None) → pinecone.index.InfoResult

Returns information about the index.

Parameters

namespace (str, optional) – a partition in an index. Use default namespace when not specified.

Returns

Information about the index.

Return type

InfoResult

query(queries: Iterable[numpy.ndarray], namespace: str = None, top_k: int = 10, include_data: bool = False, **kwargs) → Iterable[pinecone.index.QueryResult]

Sends queries to the index and returns the top results ordered by their scores.

Parameters
  • queries (Iterable[np.ndarray]) – queries

  • namespace (str, optional) – a partition in an index. Use default namespace when not specified.

  • top_k (int, optional) – defaults to 10, the number of top query results to return for each query, ordered by their scores

  • **kwargs – See below

Keyword Arguments
  • batch_size (int) – overrides the number of items to batch-process.

  • disable_progress_bar (bool) – overrides whether to disable the progress bar

Returns

For each query, retrieve its nearest neighbors in the index.

Return type

Iterable[QueryResult]

unary_delete(id: str, namespace: str = None, **kwargs) → pinecone.index.DeleteResult

Deletes one item at a time.

This method sends a unary gRPC request. See Index.delete() for details about the parameters.

unary_fetch(id: str, namespace: str = None, **kwargs) → pinecone.index.FetchResult

Fetches one item at a time.

This method sends a unary gRPC request. See Index.fetch() for details about the parameters.

unary_query(query: numpy.ndarray, namespace: str = None, top_k: int = 10, include_data: bool = False, **kwargs) → pinecone.index.UpsertResult

Sends one query at a time.

This method sends a unary gRPC request. See Index.query() for details about the parameters.

unary_upsert(item: Tuple[str, numpy.ndarray], namespace: str = None, **kwargs) → pinecone.index.UpsertResult

Upserts one item at a time.

This method sends a unary gRPC request. See Index.upsert() for details about the parameters.

upsert(items: Iterable[Tuple[str, numpy.ndarray]], namespace: str = None, **kwargs) → Iterable[pinecone.index.UpsertResult]

Inserts or updates items.

An item is an (id, vector) tuple.

Insert an item into the index, or update the item’s value by the item’s id.

Parameters
  • items (Iterable[Tuple[str, np.ndarray]]) – tuples of the form (id, numpy.ndarray). The length of an id is limited to 64 characters.

  • namespace (str, optional) – a partition in an index. Defaults to None.

  • **kwargs – See below

Keyword Arguments
  • batch_size (int) – overrides the number of items to batch-process.

  • disable_progress_bar (bool) – overrides whether to disable the progress bar

Returns

Acknowledgements of items indexed.

Return type

Iterable[UpsertResult]

class pinecone.UpsertResult(id: str)

Result of an index request.

Create new instance of UpsertResult(id,)

property id

Alias for field number 0

class pinecone.QueryResult(ids: Iterable[str], scores: Iterable[float], data: numpy.ndarray = None)

Result of a query request.

Create new instance of QueryResult(ids, scores, data)

property data

Alias for field number 2

property ids

Alias for field number 0

property scores

Alias for field number 1

class pinecone.DeleteResult(id: str)

Result of a delete request.

Create new instance of DeleteResult(id,)

property id

Alias for field number 0

class pinecone.FetchResult(id: str, vector: numpy.ndarray)

Result of a fetch request

Create new instance of FetchResult(id, vector)

property id

Alias for field number 0

property vector

Alias for field number 1

class pinecone.InfoResult(index_size: str)

Metadata of an index.

Create new instance of InfoResult(index_size,)

property index_size

Alias for field number 0

class pinecone.grpc.GRPCClientConfig(secure: bool = True, timeout: int = 20, conn_timeout: int = 1, traceroute: bool = False, reuse_channel: bool = True, retry_config: Optional[dict] = None)

GRPC client configuration options.

Parameters
  • secure – Whether to use encrypted protocol (SSL). defaults to True.

  • timeout (int, optional) – defaults to 2 seconds. Fail if gateway doesn’t receive response within timeout.

  • conn_timeout (int, optional) – defaults to 1. Timeout to retry connection if gRPC is unavailable. 0 is no retry.

  • traceroute (bool, optional) – Whether to send receipts back to the gateway from each stage of the graph

  • reuse_channel – Whether to reuse the same grpc channel for multiple requests

Create new instance of GRPCClientConfig(secure, timeout, conn_timeout, traceroute, reuse_channel, retry_config)

property conn_timeout

Alias for field number 2

property retry_config

Alias for field number 5

property reuse_channel

Alias for field number 4

property secure

Alias for field number 0

property timeout

Alias for field number 1

property traceroute

Alias for field number 3