Struct tantivy::SnippetGenerator [−][src]
pub struct SnippetGenerator { /* fields omitted */ }
SnippetGenerator
Example
use tantivy::SnippetGenerator; // ... let query = query_parser.parse_query("haleurs flamands").unwrap(); let mut snippet_generator = SnippetGenerator::new(&searcher, &*query, text_field)?; snippet_generator.set_max_num_chars(100); let snippet = snippet_generator.snippet_from_doc(&doc); let snippet_html: String = snippet.to_html(); assert_eq!(snippet_html, "Comme je descendais des Fleuves impassibles,\n Je ne me sentis plus guidé par les <b>haleurs</b> :\n Des");
Methods
impl SnippetGenerator
[src]
impl SnippetGenerator
pub fn new(
searcher: &Searcher,
query: &Query,
field: Field
) -> Result<SnippetGenerator>
[src]
pub fn new(
searcher: &Searcher,
query: &Query,
field: Field
) -> Result<SnippetGenerator>
Creates a new snippet generator
pub fn set_max_num_chars(&mut self, max_num_chars: usize)
[src]
pub fn set_max_num_chars(&mut self, max_num_chars: usize)
Sets a maximum number of chars.
pub fn snippet_from_doc(&self, doc: &Document) -> Snippet
[src]
pub fn snippet_from_doc(&self, doc: &Document) -> Snippet
Generates a snippet for the given Document
.
This method extract the text associated to the SnippetGenerator
's field
and computes a snippet.
pub fn snippet(&self, text: &str) -> Snippet
[src]
pub fn snippet(&self, text: &str) -> Snippet
Generates a snippet for the given text.
Auto Trait Implementations
impl Send for SnippetGenerator
impl Send for SnippetGenerator
impl Sync for SnippetGenerator
impl Sync for SnippetGenerator