mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-03 20:07:09 +02:00
Improves usage of shared indexes
This commit is contained in:
parent
c79ca9679b
commit
d0b1ba20cb
2 changed files with 33 additions and 29 deletions
|
@ -389,3 +389,23 @@ pub static VECTOR_DOCUMENTS: Lazy<Value> = Lazy::new(|| {
|
|||
},
|
||||
])
|
||||
});
|
||||
|
||||
pub async fn shared_index_with_test_set() -> &'static Index<'static, Shared> {
|
||||
static INDEX: OnceCell<Index<'static, Shared>> = OnceCell::const_new();
|
||||
INDEX.get_or_init(|| async {
|
||||
let server = Server::new_shared();
|
||||
let index = server._index("SHARED_TEST_SET").to_shared();
|
||||
let url = format!("/indexes/{}/documents", urlencoding::encode(index.uid.as_ref()));
|
||||
let (response, code) = index
|
||||
.service
|
||||
.post_str(
|
||||
url,
|
||||
include_str!("../assets/test_set.json"),
|
||||
vec![("content-type", "application/json")],
|
||||
)
|
||||
.await;
|
||||
assert_eq!(code, 202);
|
||||
index.wait_task(response.uid()).await;
|
||||
index
|
||||
}).await
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue