const responseRange = await index.range(
  {
    cursor: 0,
    limit: 2,
    includeMetadata: true,
  },
  { namespace: "my-namespace" }
);

/*
{
  nextCursor: '2',
  vectors: [
    { 
      id: '0',
      metadata: {
        keyword: "Vector"
      } 
    },
    { 
      id: '19',
      metadata: {
        keyword: "Redis"
      } 
    }
  ]
}
*/

The range method is used to retrieve vectors in chunks with pagination. This method supports a variety of options to configure the query to your needs.

The range command is stateless, meaning you need to pass all of the parameters in each subsequent request.

Arguments

cursor
string | number
required

The cursor to the last retrieved vector. Should be set to 0 in the initial range request.

prefix
string

An string prefix to match vector IDs. All vectors with IDs that start with this prefix will be retrieved.

limit
number
required

The number of maximum vectors wanted in the response of range. (page size)

includeMetadata
boolean

Whether to include the metadata of the vectors in the response. Setting this true would be the best practice, since it will make it easier to identify the vectors.

includeVectors
boolean

Whether to include the vector themselves in the response.

includeData
boolean

Whether to include the data field in the response.

Response

RangeResponse
required
nextCursor
string | number
required

Cursor to use in the next range request.

vectors
Vector | Vector[]
required
id
string | number
required

The ID of the vector

vector
number[]

The vectors (if includeVectors is set to true)

metadata
Record<string, unknown>

The metadata of the vectors (if includeMetadata is set to true)

data
string

The data of the vector (if includeData is set to true)

const responseRange = await index.range(
  {
    cursor: 0,
    limit: 2,
    includeMetadata: true,
  },
  { namespace: "my-namespace" }
);

/*
{
  nextCursor: '2',
  vectors: [
    { 
      id: '0',
      metadata: {
        keyword: "Vector"
      } 
    },
    { 
      id: '19',
      metadata: {
        keyword: "Redis"
      } 
    }
  ]
}
*/