summaryrefslogtreecommitdiffstats
path: root/src/schema.rs
blob: c051000a269557dc1ed29021411c9dd3953aa70a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use tantivy::schema::*;

pub fn schema() -> Schema {
    let mut schema_builder = Schema::builder();

    schema_builder.add_text_field("path", STRING | STORED);
    schema_builder.add_text_field("ft", STRING | STORED);
    schema_builder.add_u64_field("size", INDEXED | STORED);
    schema_builder.add_i64_field("created", INDEXED | STORED);
    schema_builder.add_i64_field("modified", INDEXED | STORED);
    schema_builder.add_u64_field("indexed", INDEXED | STORED);

    {
        let body_options = TextOptions::default()
            .set_stored()
            .set_indexing_options(TextFieldIndexing::default()
            .set_tokenizer("default")
            .set_index_option(IndexRecordOption::WithFreqsAndPositions));
        schema_builder.add_text_field("body", body_options);
    }

    schema_builder.build()
}