@@ -16,27 +16,29 @@ struct MilliEmbedded {
16
16
#[ pymethods]
17
17
impl MilliEmbedded {
18
18
#[ new]
19
- fn new ( index_path : & str , searchable_fields : Vec < String > , filterable_fields : HashSet < String > ) -> PyResult < Self > {
19
+ fn new ( index_path : & str , primary_key : String , searchable_fields : Vec < String > , filterable_fields : HashSet < String > ) -> PyResult < Self > {
20
20
std:: fs:: create_dir_all ( & index_path)
21
21
. map_err ( |e| PyRuntimeError :: new_err ( format ! ( "Cannot create index path: {e}" ) ) ) ?;
22
22
23
- let options = EnvOpenOptions :: new ( ) ;
23
+ let mut options = EnvOpenOptions :: new ( ) ;
24
+ options. map_size ( 100 * 1024 * 1024 * 1024 ) ; // 100 GB
24
25
let index = milli:: Index :: new ( options, index_path)
25
26
. map_err ( |e| PyRuntimeError :: new_err ( format ! ( "Cannot create index, {e}" ) ) ) ?;
26
27
27
28
let mut wtxn = index. write_txn ( ) . unwrap ( ) ;
28
29
let config = IndexerConfig :: default ( ) ;
29
30
let mut builder = Settings :: new ( & mut wtxn, & index, & config) ;
31
+ builder. set_primary_key ( primary_key) ;
30
32
builder. set_searchable_fields ( searchable_fields) ;
31
33
builder. set_filterable_fields ( filterable_fields) ;
32
- builder. set_criteria ( vec ! [
33
- Criterion :: Words ,
34
- Criterion :: Typo ,
35
- Criterion :: Proximity ,
36
- Criterion :: Attribute ,
37
- Criterion :: Sort ,
38
- Criterion :: Exactness ,
39
- ] ) ;
34
+ // builder.set_criteria(vec![
35
+ // Criterion::Proximity ,
36
+ // Criterion::Words ,
37
+ // Criterion::Typo ,
38
+ // Criterion::Attribute,
39
+ // Criterion::Sort,
40
+ // Criterion::Exactness,
41
+ // ]);
40
42
41
43
builder. execute ( |_| ( ) , || false ) . map_err ( |e| PyRuntimeError :: new_err ( format ! ( "Cannot execute index builder, {e}" ) ) ) ?;
42
44
@@ -97,7 +99,7 @@ impl MilliEmbedded {
97
99
Ok ( ( build_res. indexed_documents , build_res. number_of_documents ) )
98
100
}
99
101
100
- fn search ( & self , py : Python , query : String , return_fields : HashSet < String > ) -> PyResult < String > {
102
+ fn search ( & self , py : Python , query : String , return_fields : HashSet < String > , from : usize , length : usize ) -> PyResult < String > {
101
103
py. allow_threads ( || {
102
104
let txn = self . index . read_txn ( ) . map_err ( |e| PyRuntimeError :: new_err ( format ! ( "{}" , e) ) ) ?;
103
105
let mut ctx = SearchContext :: new ( & self . index , & txn) . map_err ( |e| PyRuntimeError :: new_err ( format ! ( "{}" , e) ) ) ?;
@@ -111,8 +113,8 @@ impl MilliEmbedded {
111
113
universe,
112
114
& None ,
113
115
GeoSortStrategy :: default ( ) ,
114
- 0 ,
115
- 20 ,
116
+ from ,
117
+ length ,
116
118
None ,
117
119
& mut DefaultSearchLogger ,
118
120
& mut DefaultSearchLogger ,
0 commit comments