tantivy backend: return tags in search results
ci/woodpecker/push/check Pipeline failed Details
ci/woodpecker/push/manual Pipeline failed Details
ci/woodpecker/push/release Pipeline was successful Details

This commit is contained in:
Olivier 'reivilibre' 2022-11-28 23:19:11 +00:00
parent bff48f35f4
commit 05a60af389
1 changed files with 15 additions and 2 deletions

View File

@ -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)