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.string
required
Unique identifier for the search result.
string | null
required
The text content of the search result. May be null for hierarchy-only results.
string
The search query that produced this result.
string
required
Full URL to the page, including any anchor.
string
required
URL to the page without the anchor/hash portion.
ContentType
required
The type of content this hit represents.
askAI: Ask AI suggestion or resultcontent: Regular page contentlvl0throughlvl6: Hierarchical heading levels
string | null
required
The anchor/hash portion of the URL, if any.
Hierarchy
object
required
Hierarchical structure representing the page organization and headings.
Highlight Results
DocSearchHitHighlightResult
required
Highlighting information showing which parts of the result matched the search query.
Snippet Results
DocSearchHitSnippetResult
required
Snippet information showing contextual excerpts around matched terms.
Ranking Information
object
Optional ranking information from Algolia explaining why this result was ranked at its position.
Autocomplete Metadata
number
Sequence ID for distinct results (used when
distinct parameter is enabled).string
Internal: The index name this result came from.
string
Internal: Query ID for analytics tracking.
object
Internal: Algolia credentials for analytics.
number
Internal: Autocomplete-assigned ID for this hit.
InternalDocSearchHit
ExtendsDocSearchHit with internal metadata used during rendering. This type is used internally by DocSearch components.
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 ofDocSearchHit used for storing hits in localStorage (recent searches, favorites). Excludes highlight and snippet data to reduce storage size.
DocSearchHit except:
_highlightResult: Highlighting information (excluded to save space)_snippetResult: Snippet information (excluded to save space)
Usage Examples
Type Relationships
- DocSearchHit: Base type from Algolia searches
- InternalDocSearchHit: Adds parent references for rendering
- StoredDocSearchHit: Optimized for localStorage (no highlights/snippets)
