rust - MeiliSearch with Rust SDK search query with limit
问题描述
I am trying to search for documents by a search value and also set a limit. The default limit set by the SDK is 20 and I would like to increase it a little bit. With a standard curl this is easy but I struggle to implement the same functionality with the Rust SDK for MeiliSearch.
curl \
'http://localhost:7700/indexes/movies/search' \
--data '{ "q": "american","limit":55 }'
the docs (https://docs.meilisearch.com/references/documents.html#get-documents) offer this solution but I don't know how to send a search query value with this approach
let documents: Vec<Movie> = movies.get_documents(None, Some(55), None).await.unwrap();
my current way to search:
let results: SearchResults<Movie> = index
.search()
.with_query(&sometestval)
.execute()
.await
.expect("Failed to execute query");
I tried to use arguments like .limit()
but nothing worked. I am not sure if I overlooked something or this functionality is currently not supported by this relatively new project. If anybody has an idea I would be happy to hear it.
解决方案
You're close, it's not called limit()
but with_limit()
.
let results: SearchResults<Movie> = index
.search()
.with_query(&sometestval)
.with_limit(55)
.execute()
.await
.expect("Failed to execute query");
See also "Limit - Search Parameters | MeiliSearch Documentation v0.18".
推荐阅读
- reactjs - 使用单个操作修改多个值或每个值的操作的优缺点是什么?为什么?
- html - ATOM 文本编辑器文本颜色因哈希而改变
- java - 有没有办法从特定行的列中获取值并将其放入下一行?
- java - aui 验证器无法处理 liferay 中的表单提交
- javascript - 有没有办法在 laracast flash 中改变生命时间?
- python - 如何根据连续索引拆分数据框?
- ios - 应用程序在后台时没有立即调用 DidRecieveRemoteNotification
- java - 给jvm添加不同的p12证书
- c# - 是否有不改变输出日期值的日期时间格式?
- java - 从 Sharedpreference 获取数据时尝试在空对象引用上调用虚拟方法