String ExtensionsGet Snippet(String, String, Snippets Options) Method
Gets a snippet for an attribute or a string.
Definition
Namespace: SphinxConnector.FluentApi.Util
Assembly: SphinxConnector (in SphinxConnector.dll) Version: 6.1.0
The highlighted text.
Assembly: SphinxConnector (in SphinxConnector.dll) Version: 6.1.0
C#
public static string GetSnippet(
this string highlightSource,
string query,
SnippetsOptions options
)VB
<ExtensionAttribute>
Public Shared Function GetSnippet (
highlightSource As String,
query As String,
options As SnippetsOptions
) As StringParameters
- highlightSource String
- The attribute or text to highlight.
- query String
- The query.
- options SnippetsOptions
- The options for building the Snippet. Supported with Sphinx 2.2.1 and Manticore.
Return Value
StringThe highlighted text.
Usage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type String. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).Example
C#
using (IFulltextSession fulltextSession = fulltextStore.StartSession())
{
string query = "my query";
var snippetOptions = new SnippetsOptions { BeforeMatch = "<i>", AfterMatch = "</i>" }
var results = fulltextSession.Query<Product>().
Match(query).
Select(product => new
{
product.Id,
product.Name,
Snippet = product.Description.GetSnippet(query, snippetOptions)
}).ToList();
}