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