Documentation Index Fetch the complete documentation index at: https://algolia.com/llms.txt
Use this file to discover all available pages before exploring further.
The attributesToSnippet parameter defines which attributes should return snippets —short text fragments surrounding matched query terms.
Usage
The default snippet length is 10 words unless otherwise specified, for example "content:80".
Use "*" to apply snippets to all attributes.
To turn off snippeting, pass an empty array ([]).
Snippeting is limited to the first 50,000 characters per result (or 5,000 logograms for CJK languages).
When enabled, the search response includes a _snippetResult object.
_snippetResult
The snippeted text, with highlighting tags applied.
If truncated, the snippet ends with an ellipsis (… by default).
Customize the ellipsis with snippetEllipsisText . _snippetResult.matchLevel
Indicates how closely the attribute matched the search query.
Possible values: none, partial, full.
Examples
Set default attributes to snippet
C#
Dart
Go
Java
JavaScript
Kotlin
PHP
Python
Ruby
Scala
Swift
var response = await client . SetSettingsAsync (
"INDEX_NAME" ,
new IndexSettings
{
AttributesToSnippet = new List < string > { "content:80" , "description" },
}
);
C#
Go
Java
JavaScript
Kotlin
PHP
Python
Ruby
Scala
Swift
IndexSettings settings = new IndexSettings ()
settings . AttributesToSnippet = new List
{
"content:80" ,
"description"
};
index . SetSettings ( settings );
Snippet all attributes by default
C#
Dart
Go
Java
JavaScript
Kotlin
PHP
Python
Ruby
Scala
Swift
var response = await client . SetSettingsAsync (
"INDEX_NAME" ,
new IndexSettings { AttributesToSnippet = new List < string > { "*:80" } }
);
C#
Go
Java
JavaScript
Kotlin
PHP
Python
Ruby
Scala
Swift
IndexSettings settings = new IndexSettings ()
settings . AttributesToSnippet = new List
{
"*:80"
};
index . SetSettings ( settings );
Override default attributes to snippet for the current search
C#
Dart
Go
Java
JavaScript
Kotlin
PHP
Python
Ruby
Scala
Swift
var response = await client . SearchSingleIndexAsync < Hit >(
"INDEX_NAME" ,
new SearchParams (
new SearchParamsObject
{
Query = "query" ,
AttributesToSnippet = new List < string > { "title" , "content:80" },
}
)
);
C#
Go
Java
JavaScript
Kotlin
PHP
Python
Ruby
Scala
Swift
index . Search ( new Query ( "query" )
{
AttributesToSnippet = new List { "title" , "content:80" }
});