1pub struct SearchSchema {
2 #[allow(dead_code)]
3 pub schema: tantivy::schema::Schema,
4 pub uri: tantivy::schema::Field,
5 pub kind: tantivy::schema::Field,
6 pub title: tantivy::schema::Field,
7 pub body: tantivy::schema::Field,
8 pub fors: tantivy::schema::Field,
9 pub def_like: tantivy::schema::Field,
10}
11impl SearchSchema {
12 #[inline]
13 #[must_use]
14 pub fn get() -> &'static Self {
15 static SCHEMA: std::sync::LazyLock<SearchSchema> = std::sync::LazyLock::new(|| {
16 use tantivy::schema::{INDEXED, STORED, Schema, TEXT};
17 let mut schema = Schema::builder();
25 let kind = schema.add_u64_field("kind", INDEXED | STORED);
26 let uri = schema.add_text_field("uri", STORED);
27 let def_like = schema.add_bool_field("deflike", INDEXED | STORED);
28 let fors = schema.add_text_field("for", STORED);
29 let title = schema.add_text_field("title", TEXT);
30 let body = schema.add_text_field("body", TEXT); let schema = schema.build();
33 SearchSchema {
34 schema,
35 uri,
36 kind,
37 title,
38 body,
39 fors,
40 def_like,
41 }
42 });
43
44 &SCHEMA
45 }
46}