From 6c9ef912e6c3a9faee833c5ce3956187442e9a44 Mon Sep 17 00:00:00 2001 From: Bill Thiede Date: Sun, 29 Sep 2024 16:41:13 -0700 Subject: [PATCH] server: don't touch tantivy if no uids reindexed --- server/src/tantivy.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/server/src/tantivy.rs b/server/src/tantivy.rs index f5ac0b7..e487416 100644 --- a/server/src/tantivy.rs +++ b/server/src/tantivy.rs @@ -4,7 +4,7 @@ use log::{debug, error, info}; use sqlx::{postgres::PgPool, types::time::PrimitiveDateTime}; use tantivy::{ collector::{DocSetCollector, TopDocs}, - query, + doc, query, query::{AllQuery, BooleanQuery, Occur, QueryParser, TermQuery}, schema::{Facet, IndexRecordOption, Value}, DocAddress, Index, Searcher, TantivyDocument, TantivyError, Term, @@ -102,8 +102,10 @@ impl TantivyConnection { self.reindex_uids(pool, &uids).await } async fn reindex_uids(&self, pool: &PgPool, uids: &[String]) -> Result<(), ServerError> { + if uids.is_empty() { + return Ok(()); + } // TODO: add SlurpContents and convert HTML to text - use tantivy::{doc, Term}; let start_time = std::time::Instant::now(); let pool: &PgPool = pool;