33
44import com .microsoft .semantickernel .data .jdbc .JDBCVectorStore ;
55import com .microsoft .semantickernel .data .jdbc .JDBCVectorStoreOptions ;
6- import com .microsoft .semantickernel .data .jdbc .JDBCVectorStoreRecordCollection ;
76import com .microsoft .semantickernel .data .jdbc .JDBCVectorStoreRecordCollectionOptions ;
8- import com .microsoft .semantickernel .data .jdbc .postgres .PostgreSQLVectorStoreQueryProvider ;
9- import com .microsoft .semantickernel .samples .documentationexamples .data .index .Hotel ;
7+ import com .microsoft .semantickernel .data .jdbc .oracle .OracleVectorStoreQueryProvider ;
8+ import com .microsoft .semantickernel .data .vectorstorage .VectorStoreRecordCollection ;
9+ import java .sql .SQLException ;
10+ import java .util .Arrays ;
11+ import java .util .List ;
12+ import oracle .jdbc .datasource .impl .OracleDataSource ;
1013
1114public class Main {
12- public static void main (String [] args ) {
15+ public static void main (String [] args ) throws SQLException {
16+
1317 // Configure the data source
1418 OracleDataSource dataSource = new OracleDataSource ();
1519 dataSource .setURL ("jdbc:oracle:thin:@localhost:1521/FREEPDB1" );
@@ -29,50 +33,35 @@ public static void main(String[] args) {
2933 .build ())
3034 .build ();
3135
32- VectorStoreRecordCollection <String , Hotel > collection = vectorStore .getCollection (
33- "skhotels " ,
34- JDBCVectorStoreRecordCollectionOptions .<Hotel >builder ()
35- .withRecordClass (Hotel .class )
36+ VectorStoreRecordCollection <String , Book > collection = vectorStore .getCollection (
37+ "books " ,
38+ JDBCVectorStoreRecordCollectionOptions .<Book >builder ()
39+ .withRecordClass (Book .class )
3640 .build ());
3741
3842 // Create the collection if it doesn't exist yet.
3943 collection .createCollectionIfNotExistsAsync ().block ();
4044
41- collection .upsertBatchAsync (getHotels () , null ).block ();
45+ collection .upsertBatchAsync (books , null ).block ();
4246
4347 // Retrieve the upserted record.
44- var retrievedHotel = collection .getAsync ("1" , null ).block ();
48+ // var retrievedBook = collection.getAsync("1", null).block();
4549
4650 // Generate a vector for your search text, using your chosen embedding generation implementation.
4751 // Just showing a placeholder method here for brevity.
4852 // var searchVector = generateEmbeddingsAsync(
49- // "I'm looking for a hotel where customer happiness is the priority.").block();
53+ // "I'm looking for a Book where customer happiness is the priority.").block();
5054
5155 // Do the search.
5256 // var searchResult = collection.searchAsync(searchVector, VectorSearchOptions.builder()
5357 // .withTop(1).build()).block();
5458
55- // Hotel record = searchResult.getResults().get(0).getRecord();
56- // System.out.printf("Found hotel description: %s\n", record.getDescription());
59+ // Book record = searchResult.getResults().get(0).getRecord();
60+ // System.out.printf("Found Book description: %s\n", record.getDescription());
5761
5862 }
5963
60- private static List <Hotel > getHotels () {
61- return Arrays .asList (
62- new Hotel ("id_1" , "Hotel 1" , 1 , "Hotel 1 description" ,
63- Arrays .asList (0.5f , 3.2f , 7.1f , -4.0f , 2.8f , 10.0f , -1.3f , 5.5f ), null , null , null ,
64- 4.0 ),
65- new Hotel ("id_2" , "Hotel 2" , 2 , "Hotel 2 description" ,
66- Arrays .asList (-2.0f , 8.1f , 0.9f , 5.4f , -3.3f , 2.2f , 9.9f , -4.5f ), null , null , null ,
67- 4.0 ),
68- new Hotel ("id_3" , "Hotel 3" , 3 , "Hotel 3 description" ,
69- Arrays .asList (4.5f , -6.2f , 3.1f , 7.7f , -0.8f , 1.1f , -2.2f , 8.3f ), null , null , null ,
70- 5.0 ),
71- new Hotel ("id_4" , "Hotel 4" , 4 , "Hotel 4 description" ,
72- Arrays .asList (7.0f , 1.2f , -5.3f , 2.5f , 6.6f , -7.8f , 3.9f , -0.1f ), null , null , null ,
73- 4.0 ),
74- new Hotel ("id_5" , "Hotel 5" , 5 , "Hotel 5 description" ,
75- Arrays .asList (-3.5f , 4.4f , -1.2f , 9.9f , 5.7f , -6.1f , 7.8f , -2.0f ), null , null , null ,
76- 4.0 ));
77- }
64+ static List <Book > books = Arrays .asList (
65+ new Book ("1" , "one" , "sking" , 0 , null , "sum" , null ));
66+
7867}
0 commit comments