Crates.io | tantivy-ik |
lib.rs | tantivy-ik |
version | 0.7.0 |
source | src |
created_at | 2022-12-20 10:09:57.447048 |
updated_at | 2024-01-17 10:56:10.494127 |
description | chinese segment, ik-rs for tantivy |
homepage | https://github.com/blueshen/tantivy-ik |
repository | https://github.com/blueshen/tantivy-ik |
max_upload_size | |
id | 742175 |
size | 36,676 |
Cargo.toml
[dependencies]
tantivy-ik = "0.7.0"
mod tests {
use ik_rs::core::ik_segmenter::TokenMode;
use ik_rs::IkTokenizer;
use tantivy::Index;
use tantivy::schema::{IndexRecordOption, Schema, TextFieldIndexing, TextOptions};
#[test]
fn it_works() {
let mut schema_builder = Schema::builder();
let text_field_indexing = TextFieldIndexing::default()
.set_tokenizer("ik-index")
.set_index_option(IndexRecordOption::WithFreqsAndPositions);
let text_options = TextOptions::default()
.set_indexing_options(text_field_indexing)
.set_stored();
schema_builder.add_text_field("title", text_options);
let schema = schema_builder.build();
let index = Index::create_in_ram(schema.clone());
index
.tokenizers()
.register("ik-index", IkTokenizer::new(TokenMode::INDEX));
index
.tokenizers()
.register("ik-search", IkTokenizer::new(TokenMode::SEARCH));
}
}
Welcome rust developer and search engine developer join us, and maintain this project together!
you can PR or submit issue...
and star⭐️ or fork this project to support me!