如果用过 ES,会感到非常熟悉,具体包括以下步骤:
第一步:编写索引配置文件 (以 wiki 为例),保存到当前目录:
{
"default_search_fields": ["body", "title"], // If you do not specify fields in your query, those fields will be used.
"field_mappings": [
{
"name": "body",
"type": "text"
},
{
"name": "title",
"type": "text"
},
{
"name": "url",
"type": "text",
"indexed": false, // Field not indexed, you will not be able to search on this field.
"stored": false // Field not stored.
}
]
}
第二步:创建索引:
$ https://blog.51cto.com/u_15683898/quickwit new --index-uri file:///$(pwd)/wikipedia --index-config-path https://blog.51cto.com/u_15683898/wiki_index_config.json
其中, 是空文件夹
第三步:添加一些文档(需提前下载文档文件到当前目录):
https://blog.51cto.com/u_15683898/quickwit index --index-uri file:///$(pwd)/wikipedia --input-path wiki-articles-10000.json
文档看起来是这样:
$ head -1 wiki-articles-10000.json
{"url":"https://en.wikipedia.org/wiki?curid=48687903","title":"Jeon Hye-jin (actress, born 1988)","body":"
Jeon Hye-jin (actress, born 1988)
Jeon Hye-jin (born June 17, 1988) is a South Korean actress.
Personal life.
Jeon married his "Smile, You" co-star Lee Chun-hee on March 11, 2011. Their daughter, Lee So Yu, was born on July 30, 2011.
"}
第四步:启动 Server:
$ https://blog.51cto.com/u_15683898/quickwit serve --index-uri file:///$(pwd)/wikipedia
然后就可以进行 Query 了:
$ curl "http://0.0.0.0:8080/api/v1/wikipedia/search?query=barack+AND+obama"
# 指定 field
$ curl "http://0.0.0.0:8080/api/v1/wikipedia/search?query=body:barack+AND+obama"
文件目录如下:
$ tree . -L 2
.
├── quickwit
├── wiki-articles-10000.json
├── wiki_index_config.json
└── wikipedia
├── 7fc17075-3a78-4071-be53-e7941023c94a
└── quickwit.json
噢,差点忘了,它还同时提供 gRPC 接口,默认 8082 端口;)
文档:Search more with less | Search more with less
GitHub 地址:quickwit-inc/quickwit: Quickwit is a highly cost-efficient search engine in Rust.
最后,顺带再安利一下另一个酷炫的搜索引擎:meilisearch/MeiliSearch: Powerful, fast, and an easy to use search engine。
一旦 后,只需:
$ libreddit
Reddit 就启动了。
主页:Libreddit
GitHub 地址:spikecodes/libreddit: Private front-end for Reddit written in Rust
QUIC: QUIC - Wikipedia
GitHub 地址:cloudflare/quiche: 🥧 Savoury implementation of the QUIC transport protocol and HTTP/3
正常打出来是这样的:
let complex_structure = vec![
vec![Some(1), Some(2), Some(3), None],
vec![Some(2), None],
vec![Some(4), Some(7)],
vec![Some(1), Some(2), Some(3), None],
];
// 单行
let one_line = format!("{:?}", complex_structure);
assert_eq!(one_line, "[[Some(1), Some(2), Some(3), None], [Some(2), None], [Some(4), Some(7)], [Some(1), Some(2), Some(3), None]]");
// 多行
let many_lines = format!("{:#?}", complex_structure);
assert_eq!(many_lines, "[
[
Some(
1,
),
Some(
2,
),
Some(
3,
),
None,
],
[
Some(
2,
),
None,
],
[
Some(
4,
),
Some(
7,
),
],
[
Some(
1,
),
Some(
2,
),
Some(
3,
),
None,
],
]")
使用本模块转为 String 打出来是这样的:
use debug2::pprint;
let complex_structure = vec![
vec![Some(1), Some(2), Some(3), None],
vec![Some(2), None],
vec![Some(4), Some(7)],
vec![Some(1), Some(2), Some(3), None],
vec![Some(2), None],
vec![Some(4), Some(7)],
vec![Some(1), Some(2), Some(3), None],
vec![Some(2), None],
vec![Some(4), Some(7)],
];
assert_eq!(
pprint(complex_structure),
"
[
[Some(1), Some(2), Some(3), None],
[Some(2), None],
[Some(4), Some(7)],
[Some(1), Some(2), Some(3), None],
[Some(2), None],
[Some(4), Some(7)],
[Some(1), Some(2), Some(3), None],
[Some(2), None],
[Some(4), Some(7)],
]"
);
看起来舒服多了。
GitHub 地址:aDotInTheVoid/debug2: Space Efficient Pretty Printer
Quilkin 是一种非透明 UDP 代理,专门设计用于大型多人专用游戏服务器部署,以确保安全性、访问控制、遥测数据、指标等。
GitHub 地址:googleforgames/quilkin: Quilkin is a non-transparent UDP proxy specifically designed for use with large scale multiplayer dedicated game server deployments, to ensure security, access control, telemetry data, metrics and more.
GitHub 地址:lmt-swallow/puppy-browser: An example implementation of a tiny Web browser for educational purposes.
社区学习交流平台订阅:
本网信息来自于互联网,目的在于传递更多信息,并不代表本网赞同其观点。其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,并请自行核实相关内容。本站不承担此类作品侵权行为的直接责任及连带责任。如若本网有任何内容侵犯您的权益,请及时联系我们,本站将会在24小时内处理完毕,E-mail:xinmeigg88@163.com
本文链接:http://www.ksxb.net/tnews/2273.html