 | IFulltextSessionBuildSnippetsAsyncTDocument Method (IEnumerableString, String, SnippetsOptions) |
Builds snippets for the given data using the text processing settings from the index for the given
document type.
Namespace:
SphinxConnector.FluentApi
Assembly:
SphinxConnector (in SphinxConnector.dll) Version: 5.4.1
SyntaxTask<IList<string>> BuildSnippetsAsync<TDocument>(
IEnumerable<string> data,
string query,
SnippetsOptions options
)
Function BuildSnippetsAsync(Of TDocument) (
data As IEnumerable(Of String),
query As String,
options As SnippetsOptions
) As Task(Of IList(Of String))
Parameters
- data
- Type: System.Collections.GenericIEnumerableString
The data to build snippets for. - query
- Type: SystemString
The query to build snippets for. - options
- Type: SphinxConnector.FluentApiSnippetsOptions
The options to use.
Type Parameters
- TDocument
- The document type to build snippets for. This determines the index to take the text processing settings from.
Return Value
Type:
TaskIListStringA list of strings with the snippets.
Exceptions
Examples
Suppose you have the following class representing a document in your index:
using (IFulltextSession fulltextSession = fulltextStore.StartSession())
{
var results = await fulltextSession.Query<Product>().
Match("my query").
ToList();
var descriptionSnippets = await fulltextSession.BuildSnippetsAsync<Product>(results.Select(p => p.Description), "my query", new SnippetsOptions
{
BeforeMatch = "<i>",
AfterMatch = "</i>",
HtmlStripMode = HtmlStripMode.Strip
}););
}
See Also