Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get rid of base64 #9

Merged
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
1 change: 0 additions & 1 deletion rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ cbindgen = "0.27.0"
tantivy = "0.22.0"
cbindgen = "0.27.0"
log = "0.4.21"
base64 = "0.22.1"
env_logger = "0.11.3"
serde_json = "1.0.117"
serde = { version = "1.0.203", features = ["derive"] }
Expand Down
6 changes: 2 additions & 4 deletions rust/src/tantivy_util/highlights.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use base64::Engine;
use base64::engine::general_purpose;
use log::debug;
use tantivy::query::Query;
use tantivy::{Searcher, SnippetGenerator, TantivyDocument, TantivyError};
use tantivy::schema::Schema;
Expand All @@ -24,14 +23,13 @@ pub fn find_highlights(
.filter_map(|highlight| {
if highlight.is_empty() { None } else { Some((highlight.start, highlight.end)) }
}).collect();

if highlighted.is_empty() {
continue;
}
highlights.push(Highlight {
field_name: schema.get_field_name(field_value.field).to_string(),
fragment: Fragment {
t: general_purpose::STANDARD.encode(&snippet.fragment().to_owned()), //to comply with bleve temporarily
t: snippet.fragment().to_owned(),
r: highlighted,
},
});
Expand Down
2 changes: 1 addition & 1 deletion tantivy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ func Test(t *testing.T) {
sCtx := tantivy_go.NewSearchContextBuilder().
SetQuery("apple").
SetDocsLimit(100).
SetWithHighlights(false).
SetWithHighlights(true).
AddField(NameTitle, 1.0).
AddField(NameBody, 1.0).
Build()
Expand Down
Loading