Skip to content

Commit

Permalink
Merge pull request #9 from anyproto/go-4369-research-jieba-add-weights
Browse files Browse the repository at this point in the history
Get rid of base64
  • Loading branch information
fat-fellow authored Nov 5, 2024
2 parents 246130d + fde73bf commit 51a7d0a
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
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

0 comments on commit 51a7d0a

Please sign in to comment.