@@ -66,9 +66,9 @@ public class Index implements IndexInterface<UpsertResponse,
66
66
* Index index = client.getIndexConnection("my-index");
67
67
* }</pre>
68
68
*
69
- * @param config The {@link PineconeConfig} configuration of the index.
69
+ * @param config The {@link PineconeConfig} configuration of the index.
70
70
* @param connection The {@link PineconeConnection} configuration to be used for this index.
71
- * @param indexName The name of the index to interact with. The index host will be automatically resolved.
71
+ * @param indexName The name of the index to interact with. The index host will be automatically resolved.
72
72
* @throws PineconeValidationException if the connection object is null.
73
73
*/
74
74
public Index (PineconeConfig config , PineconeConnection connection , String indexName ) {
@@ -813,7 +813,7 @@ public DescribeIndexStatsResponse describeIndexStats(Struct filter) {
813
813
/**
814
814
* {@inheritDoc}
815
815
* <p> Example:
816
- * <pre>{@code
816
+ * <pre>{@code
817
817
* import io.pinecone.proto.ListResponse;
818
818
*
819
819
* ...
@@ -832,7 +832,7 @@ public ListResponse list() {
832
832
/**
833
833
* {@inheritDoc}
834
834
* <p>Example:
835
- * <pre>{@code
835
+ * <pre>{@code
836
836
* import io.pinecone.proto.ListResponse;
837
837
*
838
838
* ...
@@ -850,7 +850,7 @@ public ListResponse list(String namespace) {
850
850
/**
851
851
* {@inheritDoc}
852
852
* <p>Example:
853
- * <pre>{@code
853
+ * <pre>{@code
854
854
* import io.pinecone.proto.ListResponse;
855
855
*
856
856
* ...
@@ -868,7 +868,7 @@ public ListResponse list(String namespace, int limit, String paginationToken) {
868
868
/**
869
869
* {@inheritDoc}
870
870
* <p>Example:
871
- * <pre>{@code
871
+ * <pre>{@code
872
872
* import io.pinecone.proto.ListResponse;
873
873
*
874
874
* ...
@@ -886,7 +886,7 @@ public ListResponse list(String namespace, int limit) {
886
886
/**
887
887
* {@inheritDoc}
888
888
* <p>Example:
889
- * <pre>{@code
889
+ * <pre>{@code
890
890
* import io.pinecone.proto.ListResponse;
891
891
*
892
892
* ...
@@ -905,7 +905,7 @@ public ListResponse list(String namespace, String prefix) {
905
905
/**
906
906
* {@inheritDoc}
907
907
* <p> Example:
908
- * <pre>{@code
908
+ * <pre>{@code
909
909
* import io.pinecone.proto.ListResponse;
910
910
*
911
911
* ...
@@ -925,7 +925,7 @@ public ListResponse list(String namespace, String prefix, int limit) {
925
925
/**
926
926
* {@inheritDoc}
927
927
* <p>Example:
928
- * <pre>{@code
928
+ * <pre>{@code
929
929
* import io.pinecone.proto.ListResponse;
930
930
*
931
931
* ...
@@ -950,22 +950,23 @@ public ListResponse list(String namespace, String prefix, String paginationToken
950
950
* through a list of vector IDs. It then makes a synchronous RPC call to fetch the list of vector IDs.
951
951
*
952
952
* <p>Example:
953
- * <pre>{@code
953
+ * <pre>{@code
954
954
* import io.pinecone.proto.ListResponse;
955
955
*
956
956
* ...
957
957
*
958
958
* ListResponse listResponse = index.list("example-namespace", "st-", "some-pagToken", 10);
959
959
* }</pre>
960
- * @param namespace The namespace that holds the vector IDs you want to retrieve. If namespace is not specified,
961
- * the default namespace is used.
962
- * @param prefix The prefix with which vector IDs must start to be included in the response.
960
+ *
961
+ * @param namespace The namespace that holds the vector IDs you want to retrieve. If namespace is not specified,
962
+ * the default namespace is used.
963
+ * @param prefix The prefix with which vector IDs must start to be included in the response.
963
964
* @param paginationToken The token to paginate through the list of vector IDs.
964
- * @param limit The maximum number of vector IDs you want to retrieve.
965
+ * @param limit The maximum number of vector IDs you want to retrieve.
965
966
* @return {@link ListResponse} containing the list of vector IDs fetched from the specified namespace.
966
- * The response includes vector IDs up to {@code 100} items.
967
+ * The response includes vector IDs up to {@code 100} items.
967
968
* @throws RuntimeException if there are issues processing the request or communicating with the server.
968
- * This includes network issues, server errors, or serialization issues with the request or response.
969
+ * This includes network issues, server errors, or serialization issues with the request or response.
969
970
*/
970
971
public ListResponse list (String namespace , String prefix , String paginationToken , int limit ) {
971
972
validateListEndpointParameters (namespace , prefix , paginationToken , limit , true , true , true , true );
@@ -974,17 +975,81 @@ public ListResponse list(String namespace, String prefix, String paginationToken
974
975
return blockingStub .list (listRequest );
975
976
}
976
977
978
+ /**
979
+ * <p>Upserts records into a specified namespace within a Pinecone index. This operation
980
+ * will insert new records or update existing ones based on the provided data.</p>
981
+ *
982
+ * <p>The method sends a list of {@link UpsertRecord} objects to the specified namespace
983
+ * in the Pinecone index, either inserting new records or updating existing records
984
+ * depending on whether the record IDs already exist.</p>
985
+ *
986
+ * <p>Example:
987
+ * <pre>{@code
988
+ * List<UpsertRecord> records = new ArrayList<>();
989
+ * records.add(new UpsertRecord("rec1", "Apple's first product, the Apple I, was released in 1976.", "product"));
990
+ * records.add(new UpsertRecord("rec2", "Apples are a great source of dietary fiber.", "nutrition"));
991
+ *
992
+ * try {
993
+ * index.upsertRecords("example-namespace", records);
994
+ * } catch (ApiException e) {
995
+ *
996
+ * }
997
+ * }</pre></p>
998
+ *
999
+ * @param namespace The namespace within the Pinecone index where the records will be upserted.
1000
+ * The namespace must be an existing namespace or a valid one to create new records.
1001
+ * @param upsertRecord A list of {@link UpsertRecord} objects containing the records to be upserted.
1002
+ * Each record must include a unique ID and the data to be stored.
1003
+ * @throws ApiException If there is an issue with the upsert operation. This could include network errors,
1004
+ * invalid input data, or issues communicating with the Pinecone service.
1005
+ */
977
1006
public void upsertRecords (String namespace , List <UpsertRecord > upsertRecord ) throws ApiException {
978
1007
vectorOperations .upsertRecordsNamespace (namespace , upsertRecord );
979
1008
}
980
1009
981
- public SearchRecordsResponse searchRecords (String id , String namespace , Object filter , int topK , SearchRecordsVector vector ) throws ApiException {
982
- SearchRecordsRequestQuery searchRecordsRequestquery = new SearchRecordsRequestQuery ()
983
- .id (id )
984
- .filter (filter )
985
- .topK (topK )
986
- .vector (vector );
987
- SearchRecordsRequest request = new SearchRecordsRequest ().query (searchRecordsRequestquery );
1010
+ /**
1011
+ * <p>Searches for records in a specified namespace within a Pinecone index by converting a query into a vector embedding.
1012
+ * Optionally, a reranking operation can be applied to refine the results.</p>
1013
+ *
1014
+ * <p>This method sends a search query along with specified fields to the Pinecone index, retrieves the relevant records,
1015
+ * and applies an optional reranking operation if provided.</p>
1016
+ *
1017
+ * <p>Example:
1018
+ * <pre>{@code
1019
+ * String namespace = "example-namespace";
1020
+ * HashMap<String, String> inputsMap = new HashMap<>();
1021
+ * inputsMap.put("text", "Disease prevention");
1022
+ * SearchRecordsRequestQuery query = new SearchRecordsRequestQuery()
1023
+ * .topK(3)
1024
+ * .inputs(inputsMap);
1025
+ *
1026
+ * List<String> fields = new ArrayList<>();
1027
+ * fields.add("category");
1028
+ * fields.add("chunk_text");
1029
+ *
1030
+ * SearchRecordsResponse recordsResponse = index.searchRecords(namespace, query, fields, null);
1031
+ * }</pre></p>
1032
+ *
1033
+ * @param namespace The namespace within the Pinecone index where the search will be performed.
1034
+ * The namespace must exist and contain records to search through.
1035
+ * @param query The query to be converted into a vector embedding for the search operation.
1036
+ * This query contains the input data for the search and parameters like topK for result limits.
1037
+ * @param fields A list of fields to be searched within the records. These fields define which parts of the records
1038
+ * are considered during the search.
1039
+ * @param rerank (Optional) A reranking operation that can be applied to refine or reorder the search results.
1040
+ * Pass null if no reranking is required.
1041
+ * @return A {@link SearchRecordsResponse} object containing the search results, including the top matching records.
1042
+ * @throws ApiException If there is an issue with the search operation. This could include network errors,
1043
+ * invalid input data, or issues communicating with the Pinecone service.
1044
+ */
1045
+ public SearchRecordsResponse searchRecords (String namespace ,
1046
+ SearchRecordsRequestQuery query ,
1047
+ List <String > fields ,
1048
+ SearchRecordsRequestRerank rerank ) throws ApiException {
1049
+ SearchRecordsRequest request = new SearchRecordsRequest ()
1050
+ .query (query )
1051
+ .fields (fields )
1052
+ .rerank (rerank );
988
1053
989
1054
return vectorOperations .searchRecordsNamespace (namespace , request );
990
1055
}
0 commit comments