Skip to content

Commit

Permalink
chore(index): skip web documents if body is empty (#2831)
Browse files Browse the repository at this point in the history
* chore(index): skip web documents if body is empty

* Update .changes/unreleased/Fixed and Improvements-20240811-124728.yaml
  • Loading branch information
wsxiaoys authored Aug 11, 2024
1 parent 4d3f889 commit 6c60ca4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
kind: Fixed and Improvements
body: Skip web documents if body is empty
time: 2024-08-11T12:47:28.678694-07:00
11 changes: 7 additions & 4 deletions crates/tabby-index/src/doc/public.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,18 @@ impl DocIndexer {
};

stream! {
let is_document_empty = document.body.trim().is_empty();
let (id, s) = self.builder.build(document).await;
self.indexer.delete(&id);
for await doc in s.buffer_unordered(std::cmp::max(std::thread::available_parallelism().unwrap().get() * 2, 32)) {
if let Ok(Some(doc)) = doc {
self.indexer.add(doc).await;

if !is_document_empty {
for await doc in s.buffer_unordered(std::cmp::max(std::thread::available_parallelism().unwrap().get() * 2, 32)) {
if let Ok(Some(doc)) = doc {
self.indexer.add(doc).await;
}
}
}
}.count().await;

true
}

Expand Down

0 comments on commit 6c60ca4

Please sign in to comment.