Skip to content

Commit a24a97f

Browse files
committed
New endpoint - listVectorIds with a response holder and JSON format
1 parent 6d3cd72 commit a24a97f

File tree

5 files changed

+64
-0
lines changed

5 files changed

+64
-0
lines changed

pinecone-client/src/main/scala/io/cequence/pineconescala/JsonFormats.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ object JsonFormats {
1515
implicit val matchFormat: Format[Match] = Json.format[Match]
1616
implicit val queryResultFormat: Format[QueryResponse] = Json.format[QueryResponse]
1717
implicit val fetchResponseFormat: Format[FetchResponse] = Json.format[FetchResponse]
18+
implicit val vectorIdFormat: Format[VectorId] = Json.format[VectorId]
19+
implicit val listVectorIdsPaginationFormat: Format[ListVectorIdsPagination] = Json.format[ListVectorIdsPagination]
20+
implicit val listVectorIdsResponseFormat: Format[ListVectorIdsResponse] = Json.format[ListVectorIdsResponse]
21+
1822

1923
// index/collection formats
2024
implicit val collectionInfoFormat: Format[CollectionInfo] = Json.format[CollectionInfo]

pinecone-client/src/main/scala/io/cequence/pineconescala/service/EndPoint.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ object EndPoint {
99
case object query extends EndPoint
1010
case object vectors_delete extends EndPoint("vectors/delete")
1111
case object vectors_fetch extends EndPoint("vectors/fetch")
12+
case object vectors_list extends EndPoint("vectors/list")
1213
case object vectors_update extends EndPoint("vectors/update")
1314
case object vectors_upsert extends EndPoint("vectors/upsert")
1415
case object collections extends EndPoint
@@ -42,4 +43,7 @@ object Tag {
4243
case object metadata_config extends Tag
4344
case object source_collection extends Tag
4445
case object indexName extends Tag
46+
case object limit extends Tag
47+
case object paginationToken extends Tag
48+
case object prefix extends Tag
4549
}

pinecone-client/src/main/scala/io/cequence/pineconescala/service/PineconeVectorServiceImpl.scala

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,24 @@ private class PineconeVectorServiceImpl(
9191
_.asSafe[QueryResponse]
9292
)
9393

94+
override def listVectorIDs(
95+
namespace: String,
96+
limit: Option[Int],
97+
paginationToken: Option[String],
98+
prefix: Option[String],
99+
): Future[ListVectorIdsResponse] =
100+
execGET(
101+
EndPoint.vectors_list,
102+
params = Seq(
103+
Tag.namespace -> Some(namespace),
104+
Tag.limit -> limit,
105+
Tag.paginationToken -> paginationToken,
106+
Tag.prefix -> prefix
107+
)
108+
).map(
109+
_.asSafe[ListVectorIdsResponse]
110+
)
111+
94112
override def delete(
95113
ids: Seq[String],
96114
namespace: String
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package io.cequence.pineconescala.domain.response
2+
3+
case class ListVectorIdsResponse(
4+
vectors: Seq[VectorId],
5+
pagination: ListVectorIdsPagination,
6+
namespace: String
7+
)
8+
9+
case class VectorId(id: String)
10+
11+
case class ListVectorIdsPagination(
12+
next: Option[String],
13+
previous: Option[String]
14+
)

pinecone-core/src/main/scala/io/cequence/pineconescala/service/PineconeVectorService.scala

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,30 @@ trait PineconeVectorService extends PineconeServiceConsts {
6262
settings: QuerySettings = DefaultSettings.Query
6363
): Future[QueryResponse]
6464

65+
/**
66+
* The list operation lists the IDs of vectors in a single namespace.
67+
* An optional prefix can be passed to limit the results to IDs with a common prefix.
68+
*
69+
* It returns up to 100 IDs at a time by default in sorted order (bitwise/"C" collation).
70+
* If the limit parameter is set, list returns up to that number of IDs instead.
71+
* Whenever there are additional IDs to return, the response also includes a pagination_token that you can use to get the next batch of IDs.
72+
* When the response does not includes a pagination_token, there are no more IDs to return.
73+
*
74+
* @param namespace
75+
* @param limit
76+
* @param paginationToken
77+
* @param prefix
78+
*
79+
* @return List of vector IDs wrapped in a ListVectorIdsResponse
80+
* @see <a href="https://docs.pinecone.io/reference/list">Pinecone Doc</a>
81+
*/
82+
def listVectorIDs(
83+
namespace: String,
84+
limit: Option[Int] = None,
85+
paginationToken: Option[String] = None,
86+
prefix: Option[String] = None,
87+
): Future[ListVectorIdsResponse]
88+
6589
/**
6690
* The Delete operation deletes vectors, by id, from a single namespace.
6791
*

0 commit comments

Comments
 (0)