@@ -10,27 +10,44 @@ const client = new MeiliSearch(config)
1010const uid = 'movies_test'
1111
1212const dataset = [
13- { id : 123 , title : 'Pride and Prejudice' , comment : 'A great book' } ,
13+ { biduleidbidule : "ahaha" , id : 123 , title : 'Pride and Prejudice' , comment : 'A great book' } ,
1414 {
15+ biduleidbidule : "ahaha2" ,
1516 id : 456 ,
1617 title : 'Le Petit Prince' ,
1718 comment : 'A french book about a prince that walks on little cute planets' ,
1819 } ,
19- { id : 2 , title : 'Le Rouge et le Noir' , comment : 'Another french book' } ,
20- { id : 1 , title : 'Alice In Wonderland' , comment : 'A weird book' } ,
21- { id : 1344 , title : 'The Hobbit' , comment : 'An awesome book' } ,
20+ { biduleidbidule : "ahaha3" , id : 2 , title : 'Le Rouge et le Noir' , comment : 'Another french book' } ,
21+ { biduleidbidule : "ahaha4" , id : 1 , title : 'Alice In Wonderland' , comment : 'A weird book' } ,
22+ { biduleidbidule : "ahaha5" , id : 1344 , title : 'The Hobbit' , comment : 'An awesome book' } ,
2223 {
24+ biduleidbidule : "ahaha6" ,
2325 id : 4 ,
2426 title : 'Harry Potter and the Half-Blood Prince' ,
2527 comment : 'The best book' ,
2628 } ,
27- { id : 42 , title : "The Hitchhiker's Guide to the Galaxy" } ,
29+ { biduleidbidule : "ahaha7" , id : 42 , title : "The Hitchhiker's Guide to the Galaxy" } ,
2830]
2931
3032; ( async ( ) => {
31- // This example creates an index with 7 documents
32- const index = await client . getOrCreateIndex ( uid )
33- const { updateId } = await index . addDocuments ( dataset )
34- const res = await index . waitForPendingUpdate ( updateId )
35- console . log ( { res } )
33+ try {
34+ // This example creates an index with 7 documents
35+ // console.log(await client.getKeys())
36+ await client . deleteIndex ( uid )
37+ const index = await client . getOrCreateIndex ( uid , {
38+ // primaryKey: "id"
39+ } )
40+ // const update = await client.updateIndex(uid, {
41+ // primaryKey: "test_id"
42+ // })
43+ const { updateId } = await index . addDocuments ( dataset )
44+ const res = await index . waitForPendingUpdate ( updateId )
45+ // console.log({ res })
46+ // const docs = await index.search("harry")
47+ // console.log(docs.hits)
48+ const i = await client . index ( uid ) . getRawInfo ( )
49+ console . log ( i )
50+ } catch ( e ) {
51+ console . log ( e )
52+ }
3653} ) ( )
0 commit comments