55import com .microsoft .semantickernel .data .jdbc .JDBCVectorStoreOptions ;
66import com .microsoft .semantickernel .data .jdbc .JDBCVectorStoreRecordCollectionOptions ;
77import com .microsoft .semantickernel .data .jdbc .oracle .OracleVectorStoreQueryProvider ;
8+ import com .microsoft .semantickernel .data .vectorsearch .VectorSearchResults ;
89import com .microsoft .semantickernel .data .vectorstorage .VectorStoreRecordCollection ;
910import java .sql .SQLException ;
1011import java .util .Arrays ;
1112import java .util .List ;
13+ import com .microsoft .semantickernel .data .vectorstorage .options .VectorSearchOptions ;
1214import oracle .jdbc .datasource .impl .OracleDataSource ;
15+ import reactor .core .publisher .Mono ;
1316
1417public class Main {
1518 public static void main (String [] args ) throws SQLException {
@@ -45,23 +48,30 @@ public static void main(String[] args) throws SQLException {
4548 collection .upsertBatchAsync (books , null ).block ();
4649
4750 // Retrieve the upserted record.
48- //var retrievedBook = collection.getAsync("1", null).block();
51+ Book retrievedBook = collection .getAsync ("2" , null ).block ();
52+
53+ System .out .println (retrievedBook .getAuthor ());
4954
5055 // Generate a vector for your search text, using your chosen embedding generation implementation.
5156 // Just showing a placeholder method here for brevity.
52- // var searchVector = generateEmbeddingsAsync(
53- // "I'm looking for a Book where customer happiness is the priority .").block();
57+ List < Float > searchVector = generateEmbeddingsAsync (
58+ "I'm looking for a horror book ." ).block ();
5459
5560 // Do the search.
56- // var searchResult = collection.searchAsync(searchVector, VectorSearchOptions.builder()
57- // .withTop(1).build()).block();
61+ VectorSearchResults < Book > searchResult = collection .searchAsync (
62+ searchVector , VectorSearchOptions . builder () .withTop (1 ).build ()).block ();
5863
59- // Book record = searchResult.getResults().get(0).getRecord();
60- // System.out.printf ("Found Book description: %s\n", record.getDescription ());
64+ retrievedBook = searchResult .getResults ().get (0 ).getRecord ();
65+ System .out .println ("Found Book: " + retrievedBook . getIsbn ());
6166
6267 }
6368
6469 static List <Book > books = Arrays .asList (
65- new Book ("1" , "one" , "sking" , 0 , null , "sum" , null ));
70+ new Book ("1" , "one" , "sking" , 0 , null , "horror" , List .of (1f , 1f )),
71+ new Book ("2" , "two" , "squeen" , 0 , null , "non-fiction" , List .of (-11f , -11f )));
72+
73+ private static Mono <List <Float >> generateEmbeddingsAsync (String text ) {
74+ return Mono .just (List .of (-0.9f , -0.9f ));
75+ }
6676
6777}
0 commit comments