v0.15-WORKINGV1

This commit is contained in:
2022-12-03 22:43:49 +05:30
parent c7c2465a87
commit 9f7731ef42
12 changed files with 504 additions and 147 deletions

View File

@@ -42,7 +42,7 @@ pub async fn delete_book(bookid: i32, client: &Client) {
}
pub async fn search_book(search: &str, page: usize, client: &Client) -> Result<Vec<BookMeili>, meilisearch_sdk::errors::Error> {
pub async fn search_book(search: &str, page: usize, client: &Client) -> Result<(Vec<BookMeili>, usize), meilisearch_sdk::errors::Error> {
// An index is where the documents are stored.
let books = client.index("books");
let results : SearchResults<BookMeili> = books.search().with_query(search).with_offset((page-1)*24)
@@ -50,7 +50,7 @@ pub async fn search_book(search: &str, page: usize, client: &Client) -> Result<V
let formatted_results : Vec<BookMeili> = (results.hits).iter().map(|r| r.result.clone()).collect();
//.iter()s.map(|r| r.formatted_result.unwrap()).collect();
return Ok(formatted_results);
return Ok((formatted_results, results.estimated_total_hits));
}