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"}
$ ./quickwit serve --index-uri file:///$(pwd)/wikipedia
$ 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
cargo install libreddit 后,只需:$ libreddit
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,
],
]")
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)],
]"
);

From 日报小组 长琴
原文作者:Rust语言中文社区;如有侵权,请联系管理员删除。