Click or drag to resize

IFulltextSessionBuildSnippetsTDocument Method (IEnumerableString, String)

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
Syntax
IList<string> BuildSnippets<TDocument>(
	IEnumerable<string> data,
	string query
)

Parameters

data
Type: System.Collections.GenericIEnumerableString
The data to build snippets for.
query
Type: SystemString
The query to build snippets for.

Type Parameters

TDocument
The document type.

Return Value

Type: IListString
A list of strings with the snippets.
Exceptions
ExceptionCondition
ObjectDisposedExceptionOccurs when the session has already been disposed.
ArgumentNullException One of data or query is null.
ArgumentExceptionquery is empty.
FulltextExceptionOccurs when there is an error during the execution of the query.
Examples
Suppose you have the following class representing a document in your index:
using (IFulltextSession fulltextSession = fulltextStore.StartSession())
{                
    var results = fulltextSession.Query<Product>().
                                  Match("my query").        
                                  ToList();

    var descriptionSnippets = fulltextSession.BuildSnippets<Product>(results.Select(p => p.Description), "my query");        
}
See Also