DocSearchHit Types
DocSearch uses several hit type definitions to represent search results at different stages of processing. These types define the structure of search results returned from Algolia and how they’re used internally.
DocSearchHit
The primary type representing a search result from Algolia. This is the base hit type returned from search queries and includes all highlighting and snippet information.
Unique identifier for the search result.
The text content of the search result. May be null for hierarchy-only results.
The search query that produced this result.
Full URL to the page, including any anchor.
URL to the page without the anchor/hash portion.
The type of content this hit represents. type ContentType = 'askAI' | 'content' | 'lvl0' | 'lvl1' | 'lvl2' | 'lvl3' | 'lvl4' | 'lvl5' | 'lvl6' ;
askAI: Ask AI suggestion or result
content: Regular page content
lvl0 through lvl6: Hierarchical heading levels
The anchor/hash portion of the URL, if any.
Hierarchy
Hierarchical structure representing the page organization and headings. Show Hierarchy Properties
Top-level heading (typically site name or main section).
Second-level heading (typically page title).
Third-level heading (subsection).
{
"lvl0" : "Documentation" ,
"lvl1" : "Getting Started" ,
"lvl2" : "Installation" ,
"lvl3" : "React" ,
"lvl4" : null ,
"lvl5" : null ,
"lvl6" : null
}
Highlight Results
_highlightResult
DocSearchHitHighlightResult
required
Highlighting information showing which parts of the result matched the search query. Show DocSearchHitHighlightResult Type
interface DocSearchHitHighlightResult {
content : DocSearchHitAttributeHighlightResult ;
hierarchy : DocSearchHitHighlightResultHierarchy ;
hierarchy_camel : DocSearchHitHighlightResultHierarchy [];
}
content
DocSearchHitAttributeHighlightResult
Highlighting information for the content field.
hierarchy
DocSearchHitHighlightResultHierarchy
Highlighting information for each hierarchy level.
hierarchy_camel
DocSearchHitHighlightResultHierarchy[]
Alternative hierarchy highlighting format.
Show DocSearchHitAttributeHighlightResult Type
interface DocSearchHitAttributeHighlightResult {
value : string ;
matchLevel : 'full' | 'none' | 'partial' ;
matchedWords : string [];
fullyHighlighted ?: boolean ;
}
The highlighted value with <mark> tags around matched portions.
matchLevel
'full' | 'none' | 'partial'
Indicates how well the attribute matched the query.
Array of words that matched in this attribute.
Whether the entire value was highlighted.
Show DocSearchHitHighlightResultHierarchy Type
interface DocSearchHitHighlightResultHierarchy {
lvl0 : DocSearchHitAttributeHighlightResult ;
lvl1 : DocSearchHitAttributeHighlightResult ;
lvl2 : DocSearchHitAttributeHighlightResult ;
lvl3 : DocSearchHitAttributeHighlightResult ;
lvl4 : DocSearchHitAttributeHighlightResult ;
lvl5 : DocSearchHitAttributeHighlightResult ;
lvl6 : DocSearchHitAttributeHighlightResult ;
}
Contains highlight results for each hierarchy level (lvl0 through lvl6).
Snippet Results
_snippetResult
DocSearchHitSnippetResult
required
Snippet information showing contextual excerpts around matched terms. Show DocSearchHitSnippetResult Type
interface DocSearchHitSnippetResult {
content : DocSearchHitAttributeSnippetResult ;
hierarchy : DocSearchHitHighlightResultHierarchy ;
hierarchy_camel : DocSearchHitHighlightResultHierarchy [];
}
content
DocSearchHitAttributeSnippetResult
Snippet information for the content field.
hierarchy
DocSearchHitHighlightResultHierarchy
Snippet information for hierarchy levels.
hierarchy_camel
DocSearchHitHighlightResultHierarchy[]
Alternative hierarchy snippet format.
Show DocSearchHitAttributeSnippetResult Type
interface DocSearchHitAttributeSnippetResult {
value : string ;
matchLevel : 'full' | 'none' | 'partial' ;
}
The snippet value with <mark> tags around matched portions.
matchLevel
'full' | 'none' | 'partial'
Indicates how well the snippet matched the query.
Optional ranking information from Algolia explaining why this result was ranked at its position. Show Ranking Info Properties
Whether this result was promoted (boosted) in the ranking.
Number of typos in the matched query.
Position of the first matched word.
Distance between matched words.
Geographic distance (if geo search is used).
Precision of the geo match.
Number of exact word matches.
Custom user-defined score.
Geographic location that matched. Distance from search point.
Sequence ID for distinct results (used when distinct parameter is enabled).
Internal: The index name this result came from.
Internal: Query ID for analytics tracking.
__autocomplete_algoliaCredentials
Internal: Algolia credentials for analytics.
Internal: Autocomplete-assigned ID for this hit.
InternalDocSearchHit
Extends DocSearchHit with internal metadata used during rendering. This type is used internally by DocSearch components.
type InternalDocSearchHit = DocSearchHit & {
__docsearch_parent : InternalDocSearchHit | null ;
};
__docsearch_parent
InternalDocSearchHit | null
Reference to the parent hit in the hierarchy. Used to group related results and build breadcrumb navigation. This creates a tree structure where child results can reference their parent headings.
StoredDocSearchHit
A lightweight version of DocSearchHit used for storing hits in localStorage (recent searches, favorites). Excludes highlight and snippet data to reduce storage size.
type StoredDocSearchHit = Omit < DocSearchHit , '_highlightResult' | '_snippetResult' >;
This type includes all properties of DocSearchHit except:
_highlightResult: Highlighting information (excluded to save space)
_snippetResult: Snippet information (excluded to save space)
Usage Examples
Transform Items
Custom Hit Component
Access Highlight Results
< DocSearch
appId = "YOUR_APP_ID"
apiKey = "YOUR_SEARCH_API_KEY"
indexName = "docs"
transformItems = { ( items : DocSearchHit []) => {
// Filter out certain types
return items . filter ( item => item . type !== 'lvl6' );
} }
/>
Type Relationships
DocSearchHit : Base type from Algolia searches
InternalDocSearchHit : Adds parent references for rendering
StoredDocSearchHit : Optimized for localStorage (no highlights/snippets)