]> git.proxmox.com Git - rustc.git/blob - vendor/elasticlunr-rs/examples/export_json.rs
New upstream version 1.64.0+dfsg1
[rustc.git] / vendor / elasticlunr-rs / examples / export_json.rs
1 use elasticlunr::Index;
2 use std::fs::File;
3 use std::io::Write;
4
5 fn main() {
6 let mut index = Index::new(&["title", "body"]);
7 index.add_doc(
8 "1",
9 &[
10 "This Week in Rust 207",
11 "Hello and welcome to another issue of This Week in Rust!",
12 ],
13 );
14 index.add_doc(
15 "2",
16 &[
17 "This Week in Rust 206",
18 "Hello and welcome to another issue of This Week in Rust!",
19 ],
20 );
21 let mut file = File::create("examples/out.json").unwrap();
22 file.write_all(index.to_json_pretty().as_bytes()).unwrap();
23 }