[Rust] Quickwit 高性能對象存儲搜索引擎

Quickwit:亞秒級延遲的對象存儲搜索引擎

如果用過 ES,會感到非常熟悉,具體包括以下步驟:

第一步:編寫索引配置文件 wiki_index_config.json(以 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. 
        }
    ]
}

第二步:創建索引:

$ ./quickwit new --index-uri file:///$(pwd)/wikipedia --index-config-path ./wiki_index_config.json

其中,wikipedia 是空文件夾

第三步:添加一些文檔(需提前下載文檔文件到當前目錄):

./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":"\nJeon Hye-jin (actress, born 1988)\n\nJeon Hye-jin (born June 17, 1988) is a South Korean actress.\nPersonal life.\nJeon married his \"Smile, You\" co-star Lee Chun-hee on March 11, 2011. Their daughter, Lee So Yu, was born on July 30, 2011.\n\n"}

第四步:啓動 Server:

$ ./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:用 Rust 編寫的 Reddit 私有前端

一旦 cargo install libreddit 後,只需:

$ libreddit

Reddit 就啓動了。

主頁:Libreddit

GitHub 地址:spikecodes/libreddit: Private front-end for Reddit written in Rust

quiche:QUIC 和 HTTP/3 的實現

QUIC: QUIC - Wikipedia

GitHub 地址:cloudflare/quiche: 🥧 Savoury implementation of the QUIC transport protocol and HTTP/3

debug2:省空間的 Printer

正常打出來是這樣的:

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 代理

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.

一個教學目的的輕量 Web 瀏覽器

GitHub 地址:lmt-swallow/puppy-browser: An example implementation of a tiny Web browser for educational purposes.

From 日報小組 長琴

社區學習交流平臺訂閱:

本文由 Readfog 進行 AMP 轉碼,版權歸原作者所有。
來源https://mp.weixin.qq.com/s/IGdNpBqmdwxb1_vTnTtTDQ