Java Client connector

I was trying to connect using the Java client 0.6.0 . Received the below error .

Exception in thread “main” io.grpc.StatusRuntimeException: INVALID_ARGUMENT: The ‘queries’ parameter has been deprecated.
at io.grpc.stub.ClientCalls.toStatusRuntimeException(ClientCalls.java:268)
at io.grpc.stub.ClientCalls.getUnchecked(ClientCalls.java:249)
at io.grpc.stub.ClientCalls.blockingUnaryCall(ClientCalls.java:167)
at io.pinecone.proto.VectorServiceGrpc$VectorServiceBlockingStub.query(VectorServiceGrpc.java:513)
at org.example.PineConeConnector.main(PineConeConnector.java:88)

I use the below code to connect to pinecode database .

try (PineconeConnection connection = pineconeClient.connect(connectionConfig)) {
Vector v1 = Vector.newBuilder()
.setId(“v1”)
.addAllValues(Floats.asList(1F, 3F, 5F))
.build();

        Vector v2 = Vector.newBuilder()
                .setId("v2")
                .addAllValues(Floats.asList(5F, 3F, 1F))
                .build();

        // Deprecated: use addValue() or addAllValues() instead of addVector() and addAllVectors() respectively
        UpsertRequest upsertRequest = UpsertRequest.newBuilder()
                .addVectors(v1)
                .addVectors(v2)
                .setNamespace(args.namespace)
                .build();

        System.out.println("Sending upsert request:");
        System.out.println(upsertRequest);

        UpsertResponse upsertResponse = connection.getBlockingStub().upsert(upsertRequest);

        System.out.println("Got upsert response:");
        System.out.println(upsertResponse);


        QueryVector queryVector = QueryVector
                .newBuilder()
                .addAllValues(Floats.asList(1F, 2F, 2F))
                .setTopK(args.topK)
                .setNamespace(args.namespace)
                .build();

        QueryRequest queryRequest = QueryRequest
                .newBuilder()
                .addQueries(queryVector)
                .setTopK(args.topK)
                .build();

        System.out.println("Sending query request:");
        System.out.println(queryRequest);

        QueryResponse queryResponse = connection.getBlockingStub().query(queryRequest);

        System.out.println("Got query response:");
        System.out.println(queryResponse);
    } catch (PineconeException e) {
        e.printStackTrace();
    }

Hi @shyamu.in. The queries parameter was deprecated some time ago; to run a query using the Java client, you now want to use a list instead of the QueryBuilder object. You can see an example of how to do this in this forum post from one of our Java engineers.

We have some improvements coming out soon that should simplify this, too. Please keep an eye on our release announcements, or the Github repo for the client.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.