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]

Creates a new snippet generator

Sets a maximum number of chars.

Generates a snippet for the given Document.

This method extract the text associated to the SnippetGenerator's field and computes a snippet.

Generates a snippet for the given text.

Auto Trait Implementations