开源项目搭建中国裁判文书网本地搜索WEB系统

# 开源项目搭建中国裁判文书网本地搜索WEB系统

2023年12月听新闻说裁判文书网将不再对公众开放,对于这个消息对于中国法制进程影响可谓深远。

今天在github上看到一个开源项目,中国裁判文书网本地搜索,处于好奇在本地搭建试一下,能否跑起来。

https://github.com/cncases/cases (opens new window)

caipanwenshuwang

# 下载原始数据(102G)

方法:通过bt下载,种子文件为 810air.torrent ,可以从本仓库下载,也可以通过链接 https://files.catbox.moe/810air.torrent (opens new window)

原始数据来源于马克数据网 (opens new window),文书数量超过8500万,约102G。下载后不要解压子文件,将文件路径填写到 config.toml 中的 raw_data_path 变量中;

我这边用迅雷下载,大概95G

image-20240130141708576

# 下载程序并创建配置文件

从 releases 页面下载已编译好的二进制文件(推荐),https://github.com/cncases/cases/releases

我用的系统是windows,所以下载的是 v0.0.5-x86_64-pc-windows-msvc.zip

image-20240130141910186

# 测试系统配置

系统: windows11 专业版

CPU: i5-10400F CPU @ 2.90GHz

内存:24G

硬盘: 1T机械硬盘 (至少要有500G的空余空间)

# 配置文件

参考配置文件: https://github.com/cncases/cases/blob/main/config.toml

配置文件参考config.toml

db = "./rocksdb"  # path to store rocksdb
index_path ="./search_index"  # path to store index
index_with_full_text = false  # whether establish full-text index
addr = "127.0.0.1:8081" # If allow LAN access, change it to "0.0.0.0:port".

# The raw data path you downloaded from the torrent, and you must NOT unzip it. 注意路径
raw_data_path = "./"

1
2
3
4
5
6
7
8
9
10

# 将数据加载到 rocksdb 数据库中

运行 convert config.toml 程序。此过程会将原始数据放入 rocksdb 数据库中,数据库文件路径为 config.toml 中的 db 变量;转换后的数据大小约为 200G,转换可能会花费数小时的时间;如果中途中断,再次运行会从中断处继续。

$ ./convert.exe config.toml

1
2

image-20240130142749752

系统资源占用情况

image-20240130143052227

开始时间: 14:30

结束时间:17:00

一共两个半小时,根据个人系统配置高低有关系。

生成rocksdb目录有184G大小。

image-20240130170639698

# 创建索引

运行 index config.toml 程序会将数据库中的数据创建索引,索引文件路径为 config.toml 中的 index_path 变量;如果中途中断,需要删除 index_path 中的文件,重新运行 index 程序;默认情况下,不会索引案件内容,索引大小约为 15.5G,可能会花费数小时的时间。如果需要索引案件内容,需要将index.toml中的 index_with_full_text 设置为 true,但是这会使索引文件增加到150G左右,索引时间也会增加到十几个小时。

$ ./index.exe config.toml
1

image-20240130170717992

开始时间: 2024-01-30 09:07:18
结束时间: 2024-02-01 03:14:18
1
2

一共花费了70多个小时

生成search_index目录有15.4G大小。

image-20240201134120524

# 运行搜索服务

运行 main config.toml 程序,用浏览器打开config.toml网址,即可搜索。

$ ./main.exe config.toml
2024-02-01T05:38:57.369799Z  INFO main: listening on http://127.0.0.1:8081
1
2

浏览器访问: http://127.0.0.1:8081

访问截图

image-20240201134047893

image-20240201134815603

至此,开源项目搭建中国裁判文书网本地搜索WEB系统完成。