Adding filters on metadata with the Java SDK

I’m using the Java SDK to interact with Pinecone. For each vector that I create, I’m adding a few metadata fields, in this case, the most important ones are named “documentId”.

I’d like to create a query to return the top values that match a given embedding but exclude a given set of document IDs. I wasn’t really sure how to do this, here’s some of the code that I’ve started with but I’m not sure where to go from here.

Any thoughts on how to best do this?

EmbeddingResult embeddingResult = this.openAiClient.getEmbeddings(Collections.singletonList(query));
Embedding embedding = embeddingResult.getData().get(0);
List<Float> queryEmbedding = embedding.getEmbedding().stream().map(Double::floatValue).collect(Collectors.toList());
PineconeConnectionConfig config = new PineconeConnectionConfig().withIndexName(this.indexName);
PineconeConnection connection = this.pineconeClient.connect(config);

/* I imagine something here needs to change */
Struct filter = null;
if (excludedDocumentIds != null && excludedDocumentIds.size() > 0) {
	filter = Struct.newBuilder()
		.putFields("documentId", Value.newBuilder()
		.setListValue(ListValue.newBuilder()				
			// Potentially something here as well but how to negate the document IDs in this list?
.addAllValues(excludedDocumentIds.stream().map(Value::newBuilder).collect(Collectors.toList()))
				.build())
			.build())
		.build();
}

	QueryRequest request = QueryRequest.newBuilder()
		.addQueries(QueryVector.newBuilder().addAllValues(queryEmbedding).build())
		.setTopK(numberOfResults)
		.setNamespace(teamId)
		.setFilter(filter)
		.setIncludeMetadata(true)
		.setIncludeValues(false)
		.build();

QueryResponse response = connection.getBlockingStub().query(request);

Thanks so much!