-
Notifications
You must be signed in to change notification settings - Fork 134
api/search #243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
api/search #243
Changes from all commits
3bf1025
9f26ccc
4a68053
3e04b4c
7d87cb5
801c61a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| [package] | ||
| name = "cases" | ||
| version = "0.2.9" | ||
| version = "0.2.12" | ||
| edition = "2024" | ||
| rust-version = "1.92" | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| 更多合作请发邮件至 contact@caseopen.org (请勿使用微软旗下邮箱服务如outlook.com) | ||
|
|
||
| ### 关键词查询语法简明指南 | ||
|
|
||
| 可用字段一览: | ||
|
|
@@ -95,6 +97,16 @@ https://docs.rs/tantivy/latest/tantivy/query/struct.QueryParser.html | |
|
|
||
| 导出功能: | ||
| 最多导出10000条,调整offset参数可获得更多结果,offset=10000,即可获得第10000~20000条结果。如: | ||
| https://caseopen.org/?search=%E6%8B%90%E5%8D%96&offset=10000&search_type=default&export=true | ||
| https://caseopen.org/?search=%E6%8B%90%E5%8D%96&offset=10000&search_type=keyword&export=true | ||
|
|
||
| ----------------------------- | ||
|
|
||
| api: | ||
|
|
||
| /api/search?search=拐卖妇女儿童 | ||
|
|
||
| 可选参数: | ||
| - search_type: keyword(默认关键词搜索)/ vsearch(语义搜索,刑事案件可用) | ||
| - offset: 偏移量,默认0 | ||
|
Comment on lines
+108
to
+110
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win Document the supported
🤖 Prompt for AI Agents |
||
|
|
||
| 更多合作请发邮件至 contact@caseopen.org | ||
| 如:/api/search?search=拐卖妇女儿童&search_type=vsearch&offset=100 | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀 Performance & Scalability | 🟠 Major | ⚡ Quick win
CaseData.full_textis unconditionally serialized for every search hit, even though nothing but CSV export needs it.The HTML template (
templates/search.html) only renderscase.preview, nevercase.full_text; the new/api/searchJSON endpoint (Lines 354-358) serializes it for every result regardless, and sinceapi_searchnever branches onsearch_meta.export, calling it withexport=trueraises the limit toEXPORT_LIMIT(10000 by default) and returns full document text for up to 10000 hits as JSON. Only the CSV branch ofsearch(Lines 320-334) actually consumescase.full_text. Excluding it from serialization keeps CSV working while avoiding a large, unintended payload/bandwidth cost on the new JSON endpoint.♻️ Suggested fix
#[derive(Serialize)] pub struct CaseData { id: u32, preview: String, doc_id: String, case_id: String, case_name: String, court: String, case_type: String, procedure: String, judgment_date: String, public_date: String, parties: String, cause: String, legal_basis: String, + #[serde(skip_serializing)] full_text: String, }📝 Committable suggestion
🤖 Prompt for AI Agents