@@ -7,51 +7,6 @@ This crate implements a searchable index for messages in a Matrix client.
77The recommended way to use this crate is to include ` matrix-sdk ` as a dependency
88in your ` Cargo.toml ` file with the ` experimental-search ` feature flag turned on.
99
10- Instantiation is done by the client builder using ` matrix_sdk::client::builder::ClientBuilder::search_index_store() ` .
11-
12- ``` rust
13- use std :: path :: Path ;
14- use matrix_sdk :: {
15- Client , ClientBuildError , SqliteCryptoStore , SqliteEventCacheStore , SqliteStateStore ,
16- config :: StoreConfig ,
17- search_index :: SearchIndexStoreKind ,
18- };
19-
20- async fn make_client (
21- name : & str ,
22- session_path : & Path ,
23- server_name : & str
24- ) -> Result <Client , ClientBuildError > {
25- Client :: builder ()
26- . store_config (
27- StoreConfig :: new (name . to_owned ())
28- . crypto_store (SqliteCryptoStore :: open (session_path . join (" crypto" ), None ). await ? )
29- . state_store (SqliteStateStore :: open (session_path . join (" state" ), None ). await ? )
30- . event_cache_store (
31- SqliteEventCacheStore :: open (session_path . join (" cache" ), None ). await ? ,
32- ),
33- )
34- . server_name_or_homeserver_url (server_name )
35- . search_index_store (SearchIndexStoreKind :: UnencryptedDirectory (session_path . join (" index" )))
36- . build ()
37- . await
38- }
39-
40- ```
41-
42- And searching is done via ` matrix_sdk::room::Room::search() ` .
43-
44- ``` rust
45- use ruma :: OwnedEventId ;
46- use matrix_sdk :: room :: Room ;
47- use matrix_sdk_search :: error :: IndexError ;
48-
49- async fn search_in_room (room : Room , query : & str ) -> Result <Vec <OwnedEventId >, IndexError > {
50- // Returns at most 100 results with no pagination offset.
51- room . search (query , 100 , None ). await
52- }
53- ```
54-
5510## Stand-alone usage
5611
5712Constructing a ` matrix_sdk_search::index::RoomIndex ` is done with the ` matrix_sdk_search::index::builder::RoomIndexBuilder ` .
0 commit comments