@@ -18,39 +18,39 @@ interface Movie {
1818 genre ?: string
1919}
2020
21- const client = new MeiliSearch ( config )
22-
23- ; ( async ( ) => {
24- const index = await client . getOrCreateIndex < Movie > ( 'movies' )
25-
26- const indexes = await client . getIndexes ( )
27- indexes . map ( ( index : IndexResponse ) => {
28- console . log ( index . uid )
29- // console.log(index.something) -> ERROR
30- } )
31-
32- const searchParams : SearchParams = {
33- limit : 5 ,
34- attributesToRetrieve : [ 'title' , 'genre' ] ,
35- attributesToHighlight : [ 'title' ] ,
36- // test: true -> ERROR Test does not exist on type SearchParams
37- }
38- indexes . map ( ( index : IndexResponse ) => index . uid )
39- const res : SearchResponse < Movie > = await index . search (
40- 'avenger' ,
41- searchParams
42- )
43-
44- // both work
45- const { hits } : { hits : Hits < Movie > } = res
46-
47- hits . map ( ( hit : Hit < Movie > ) => {
48- console . log ( hit ?. genre )
49- console . log ( hit . title )
50- // console.log(hit._formatted.title) -> ERROR, _formatted could be undefined
51- // console.log(hit?._formatted.title) -> ERROR, title could be undefined
52- console . log ( hit ?. _formatted ?. title )
53- } )
54-
55- await index . delete ( )
56- } ) ( )
21+ const client = new MeiliSearch ( config ) ;
22+
23+ ( async ( ) => {
24+ const index = await client . getOrCreateIndex < Movie > ( 'movies' )
25+
26+ const indexes = await client . getIndexes ( )
27+ indexes . map ( ( index : IndexResponse ) => {
28+ console . log ( index . uid )
29+ // console.log(index.something) -> ERROR
30+ } )
31+
32+ const searchParams : SearchParams = {
33+ limit : 5 ,
34+ attributesToRetrieve : [ 'title' , 'genre' ] ,
35+ attributesToHighlight : [ 'title' ] ,
36+ // test: true -> ERROR Test does not exist on type SearchParams
37+ }
38+ indexes . map ( ( index : IndexResponse ) => index . uid )
39+ const res : SearchResponse < Movie > = await index . search (
40+ 'avenger' ,
41+ searchParams
42+ )
43+
44+ // both work
45+ const { hits } : { hits : Hits < Movie > } = res
46+
47+ hits . map ( ( hit : Hit < Movie > ) => {
48+ console . log ( hit ?. genre )
49+ console . log ( hit . title )
50+ // console.log(hit._formatted.title) -> ERROR, _formatted could be undefined
51+ // console.log(hit?._formatted.title) -> ERROR, title could be undefined
52+ console . log ( hit ?. _formatted ?. title )
53+ } )
54+
55+ await index . delete ( )
56+ } ) ( )
0 commit comments