Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/document.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


use napi::{bindgen_prelude::*, Error, JsNumber, Result, Status, ValueType};
use napi_derive::napi;

Expand Down
2 changes: 0 additions & 2 deletions src/index.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


use std::collections::HashMap;

use napi::bindgen_prelude::*;
Expand Down
1 change: 0 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ pub(crate) fn make_term_for_type(
}
}


pub mod document;
pub mod explanation;
pub mod facet;
Expand Down
5 changes: 4 additions & 1 deletion src/parser_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,10 @@ impl IpFormatError {

impl QueryParserError for IpFormatError {
fn full_message(&self) -> String {
format!("The IP address field is malformed: {0}", self.addr_parse_error)
format!(
"The IP address field is malformed: {0}",
self.addr_parse_error
)
}
}

Expand Down
4 changes: 0 additions & 4 deletions src/searcher.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


use crate::{document::Document, query::Query};
use napi::bindgen_prelude::*;
use napi::{Error, Result, Status};
Expand All @@ -22,8 +20,6 @@ pub struct Searcher {
pub(crate) inner: tv::Searcher,
}



#[napi]
#[derive(Deserialize, PartialEq, Serialize)]
/// Enum representing the direction in which something should be sorted.
Expand Down
10 changes: 6 additions & 4 deletions src/snippet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,12 @@ impl SnippetGenerator {
schema: &crate::Schema,
field_name: String,
) -> Result<SnippetGenerator> {
let field = schema
.inner
.get_field(&field_name)
.map_err(|_| Error::new(napi::Status::InvalidArg, format!("Field '{}' not found", field_name)))?;
let field = schema.inner.get_field(&field_name).map_err(|_| {
Error::new(
napi::Status::InvalidArg,
format!("Field '{}' not found", field_name),
)
})?;
let generator = tv::snippet::SnippetGenerator::create(&searcher.inner, query.get(), field)
.map_err(|e| Error::new(napi::Status::GenericFailure, e.to_string()))?;

Expand Down
16 changes: 11 additions & 5 deletions src/tokenizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,16 +364,22 @@ impl TextAnalyzerBuilder {
Err(e) => return Err(e),
},
FilterType::StopWord { language } => match parse_language(language) {
Ok(lang) => builder.filter_dynamic(tvt::StopWordFilter::new(lang)
.ok_or_else(|| Error::from_reason(format!("Failed to create stop word filter for language: {:?}", language)))?),
Ok(lang) => builder.filter_dynamic(tvt::StopWordFilter::new(lang).ok_or_else(|| {
Error::from_reason(format!(
"Failed to create stop word filter for language: {:?}",
language
))
})?),
Err(e) => return Err(e),
},
FilterType::CustomStopWord { stopwords } => {
builder.filter_dynamic(tvt::StopWordFilter::remove(stopwords.clone()))
}
FilterType::SplitCompound { constituent_words } => builder
.filter_dynamic(tvt::SplitCompoundWords::from_dictionary(constituent_words)
.map_err(|e| Error::from_reason(format!("Failed to create compound splitter: {}", e)))?),
FilterType::SplitCompound { constituent_words } => builder.filter_dynamic(
tvt::SplitCompoundWords::from_dictionary(constituent_words).map_err(|e| {
Error::from_reason(format!("Failed to create compound splitter: {}", e))
})?,
),
};
Ok(TextAnalyzerBuilder {
builder: Some(new_builder),
Expand Down