 | 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.FluentApiAssembly: SphinxConnector (in SphinxConnector.dll) Version: 3.12.6
SyntaxIList<string> BuildSnippets<TDocument>(
IEnumerable<string> data,
string query
)
Function BuildSnippets(Of TDocument) (
data As IEnumerable(Of String),
query As String
) As IList(Of String)
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:
IListStringA list of strings with the snippets.
Exceptions
Examples
Suppose you have the following class representing a document in your index:
public class Product
{
public int Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public decimal Price { get; set; }
public int CategoryId { get; set; }
public int VendorId { get; set; }
public int Weight { get; set; }
}
using (IFulltextSession fulltextSession = fulltextStore.StartSession())
{
QueryMetadata metadata;
var results = fulltextSession.Query<Product>().
Match("my query").
ToList();
var descriptionSnippets = fulltextSession.BuildSnippets<Product>(results.Select(p => p.Description), "my query");
}
See Also