From 05a60af389455d96d0a0977cf6cf6f216d787920 Mon Sep 17 00:00:00 2001 From: Olivier Date: Mon, 28 Nov 2022 23:19:11 +0000 Subject: [PATCH] tantivy backend: return tags in search results --- quickpeep_index/src/backend/tantivy.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/quickpeep_index/src/backend/tantivy.rs b/quickpeep_index/src/backend/tantivy.rs index 6820d9a..82f2102 100644 --- a/quickpeep_index/src/backend/tantivy.rs +++ b/quickpeep_index/src/backend/tantivy.rs @@ -202,14 +202,27 @@ impl Backend for TantivyBackend { let snippet = article_snippet_generator.snippet(&doc_row.body); let excerpt = snippet.to_html(); + let tags = doc + .get_all(self.fields.tags) + .map(|fv| { + String::from( + *fv.as_facet() + .expect("tags must be facet!") + .to_path() + .last() + .unwrap_or(&""), + ) + }) + .collect(); + out.push(SearchDocument { score, title: doc_row.title, excerpt, - tags: vec![], + tags, url: url.to_owned(), favicon_url_hash: doc_row.favicon_url_hash, - }) + }); } Ok(out)