Skip to main content

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.
objectID
string
required
Unique identifier for the search result.
content
string | null
required
The text content of the search result. May be null for hierarchy-only results.
query
string
The search query that produced this result.
url
string
required
Full URL to the page, including any anchor.
url_without_anchor
string
required
URL to the page without the anchor/hash portion.
type
ContentType
required
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
anchor
string | null
required
The anchor/hash portion of the URL, if any.

Hierarchy

hierarchy
object
required
Hierarchical structure representing the page organization and headings.
{
  "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.

Snippet Results

_snippetResult
DocSearchHitSnippetResult
required
Snippet information showing contextual excerpts around matched terms.

Ranking Information

_rankingInfo
object
Optional ranking information from Algolia explaining why this result was ranked at its position.

Autocomplete Metadata

_distinctSeqID
number
Sequence ID for distinct results (used when distinct parameter is enabled).
__autocomplete_indexName
string
Internal: The index name this result came from.
__autocomplete_queryID
string
Internal: Query ID for analytics tracking.
__autocomplete_algoliaCredentials
object
Internal: Algolia credentials for analytics.
__autocomplete_id
number
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

<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)

Build docs developers (and LLMs) love