Hello Yash Deokate,
Welcome to the Microsoft Q&A and thank you for posting your questions here.
I understand that you are in need of how to set vector value while doing search in Azure AI search Java SDK.
From my understanding of this issue, the SearchQueryVector
class and its setValue
function might have been deprecated or replaced in the newer versions of the Azure AI Search Java SDK and instead, you can use the VectorSearchOptions
class to set up your vector search.
This is a basic method on how you can set the actual vectors using the VectorSearchOptions
class:
First, create a VectorQuery
object, setting the vector, the number of nearest neighbors (k
), and the fields to search. Then, add this query to the VectorSearchOptions
. Finally, execute the search with the SearchClient
.
List<Double> vector = Arrays.asList(-0.009154141, 0.018708462, -0.02178128, -0.00086512347); // Example vector
VectorQuery vectorQuery = new VectorQuery()
.setVector(vector)
.setK(5)
.setFields("contentVector");
VectorSearchOptions options = new VectorSearchOptions()
.setVectorQueries(Collections.singletonList(vectorQuery));
SearchClient searchClient = new SearchClientBuilder()
.endpoint("https://<your-search-service>.search.windows.net")
.credential(new AzureKeyCredential("<your-api-key>"))
.indexName("<your-index-name>")
.buildClient();
SearchPagedIterable searchResults = searchClient.search("", options);
This setup allows you to perform vector searches efficiently with the updated SDK.
For more detailed information, you can refer to the Azure AI Search documentation - https://learn.microsoft.com/en-us/azure/search/vector-search-how-to-query
I hope this is helpful! Do not hesitate to let me know if you have any other questions.
Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful.