New! Redpanda Agentic Data Plane is here: a governed, high-performance foundation for AI agents. Learn more
Redpanda logo Self-Managed
Cloud Self-Managed Connect Labs
or

What do you think of this page?

Let us know more:

Let us contact you about your feedback:

Please complete the “I'm not a robot” checkbox before submitting.

Version 25.3 keyboard_arrow_down
25.2 25.1 24.3 (end of life) 24.2 (end of life) 24.1 (end of life) 23.3 (end of life)
    • Overview
    • Get Started
      • What’s New
        • Redpanda
        • Operator
        • Helm Charts
      • Introduction to Redpanda
      • How Redpanda Works
      • Introduction to Redpanda Console
      • Quickstarts
        • Redpanda Self-Managed
        • Redpanda CLI Quickstart
        • Docker Compose Labs
      • Redpanda Licensing
        • Editions and Enterprise Features
        • Add License to Redpanda
          • Linux
          • Kubernetes
          • Use Redpanda Console
        • Add License to Redpanda Console
        • Check Status
          • Use rpk
          • Use Redpanda Operator
          • Use Redpanda Console
          • Use Metrics
        • Disable Enterprise Features
      • Redpanda CLI
        • Introduction to rpk
        • Install or Update rpk
        • rpk Profiles
        • Specify Broker Addresses for rpk
        • Specify Admin API Addresses for rpk
      • Partner Integrations
    • Develop
      • Kafka Compatibility
      • Benchmark Redpanda
      • Use Redpanda with the HTTP Proxy API
      • Manage Topics
      • Edit Topic Configuration
      • Produce Data
        • Configure Producers
        • Idempotent Producers
        • Leader Pinning
      • Consume Data
        • Consumer Offsets
        • Follower Fetching
        • Filter Messages
        • Deserialize Messages
      • Data Transforms
        • Overview
        • Get Started
          • Linux
          • Kubernetes
        • Build
        • Configure
        • Deploy
        • Test
        • Monitor
        • Manage in Redpanda Console
        • Upgrade
        • Versioning and Compatibility
        • Examples
      • Transactions
    • Deploy
      • Redpanda
        • Kubernetes
          • Overview
          • Get Started
            • Azure AKS
            • Amazon EKS
            • Google GKE
            • Local (kind and minikube)
          • Deployment Workflow
          • Requirements and Recommendations
          • Tune Worker Nodes
          • Deploy Redpanda
          • Production Readiness Checklist
          • High Availability
        • Linux
          • Hardware and Software Requirements
          • Deployment Options
            • Deploy for Development
            • Deploy for Production: Automated
            • Deploy for Production: Manual
            • Production Readiness Checklist
          • Sizing Use Cases
          • Sizing Guidelines
          • System Tuning
      • Redpanda Console
        • Kubernetes
          • Requirements
          • Deploy on Kubernetes
        • Linux
          • Requirements
          • Deploy on Linux
      • Redpanda Connect
      • Kafka Connect
        • Deploy on Kubernetes
        • Deploy on Docker
    • Manage
      • Kubernetes
        • Customize the Helm Chart
        • Cluster Properties
        • Manage Topics
        • Manage Kafka Connect
        • Storage
          • Volume Types
          • Configure Storage
            • PersistentVolume
            • hostPath
            • emptyDir
          • Expand PersistentVolumes
          • Delete PersistentVolumes
        • Tiered Storage
          • Use Tiered Storage
          • Fast Commission and Decommission Brokers in Kubernetes
          • Remote Read Replicas
          • Topic Recovery
          • Whole Cluster Restore
        • Networking and Connectivity
          • Overview
          • Connect to Redpanda
          • Configure Listeners
          • External Access
            • Use a NodePort Service
            • Use LoadBalancer Services
            • Use Custom Services
        • Security
          • TLS Encryption
            • Use cert-manager
            • Use Secrets
          • Authentication and Authorization
            • Enable Authentication
            • Manage Users and ACLs (Operator)
            • Manage Roles and ACLs (Operator)
          • Audit Logging
        • Rack Awareness
        • Remote Read Replicas
        • Shadowing
          • Configure Shadowing
          • Monitor
          • Failover Runbook
        • Manage Pod Resources
        • Scale
        • Enable the PVCUnbinder
        • Decommission Brokers
        • Recovery Mode
        • Monitor
          • Redpanda
          • Kafka Connect
        • Rolling Restart
        • Resilience Testing
      • Cluster Maintenance
        • Configure Cluster Properties
        • Configure Broker Properties
        • Configure Topic Properties
        • Cluster Balancing
        • Continuous Data Balancing
        • Decommission Brokers
        • Maintenance Mode
        • Rolling Restart
        • Audit Logging
          • Sample Audit Log Messages
        • Manage Disk Space
        • Manage Throughput
        • Compaction Settings
        • Configure Client Connections
        • Forced Partition Recovery
        • Node-wise Partition Recovery
      • Security
        • Authentication
        • Authorization
          • Role-Based Access Control (RBAC)
          • Access Control Lists (ACLs)
        • FIPS Compliance
        • Configure Kafka TLS Encryption
        • Configure Listeners
        • IAM Roles
      • Tiered Storage
        • Use Tiered Storage
        • Fast Commission and Decommission Brokers
        • Mountable Topics
      • Iceberg
        • About Iceberg Topics
        • Specify Iceberg Schema
        • Use Iceberg Catalogs
        • Integrate with REST Catalogs
          • AWS Glue
          • Databricks Unity Catalog
          • GCP BigLake
          • Snowflake and Open Catalog
        • Query Iceberg Topics
        • Migrate to Iceberg Topics
      • Schema Registry
        • Overview
        • Use Schema Registry
          • API
          • Kubernetes
        • Schema Registry Authorization
        • Server-Side Schema ID Validation
        • Manage in Redpanda Console
      • High Availability
      • Disaster Recovery
        • Shadowing
          • Overview
          • Configure Shadowing
          • Monitor Shadowing
          • Failover
          • Failover Runbook
        • Whole Cluster Restore
        • Topic Recovery
      • Remote Read Replicas
      • Recovery Mode
      • Rack Awareness
      • Raft Group Reconfiguration
      • Optimize I/O
      • Redpanda Console
        • Configure Redpanda Console
        • Add an Enterprise License
        • Connect to Redpanda
        • Security
          • Authentication
          • Authorization
          • TLS Termination
        • HTTP Path Rewrites
        • Deserialization
        • Topic Documentation
        • Telemetry
        • Kafka Connect
      • Use the Admin API
      • Monitor Redpanda
    • Upgrade
      • Upgrade Redpanda in Linux
      • Upgrade Redpanda in Kubernetes
      • Upgrade the Redpanda Operator
      • Kubernetes Compatibility
      • Migrate Node Pools
      • Deprecated Features
      • Iceberg Schema Changes in v25.3
    • Migrate
      • Migrate to Redpanda Console v3.0.x
      • Migrate Data to Redpanda with MirrorMaker 2
      • Migrate from the Redpanda Helm chart
      • Migrate from Strimzi to Redpanda Operator
    • Troubleshoot
      • Cluster Diagnostics
        • Linux
        • Kubernetes
      • Debug Bundles
        • Overview
        • Configure
          • Linux
          • Kubernetes
        • Generate
          • Linux
          • Kubernetes
          • Redpanda Console
        • Inspect
      • Resolve Errors
        • Linux
        • Kubernetes
    • Reference
      • Properties
        • Broker Configuration Properties
        • Cluster Configuration Properties
        • Object Storage Properties
        • Topic Configuration Properties
      • Release Notes
        • Redpanda
        • Redpanda Console
        • Redpanda Helm Chart
        • Redpanda Operator
      • API Reference
        • HTTP Proxy API
        • Schema Registry API
        • Admin API
        • Admin API (ConnectRPC)
      • Data Transforms SDKs
        • Golang
        • Rust
        • JavaScript
          • Data Transforms API
          • Schema Registry API
      • Kubernetes
        • Kubernetes Helm Chart Specifications
          • Redpanda
          • Redpanda Operator
          • Redpanda Console
          • Kafka Connect
          • Redpanda Connect
        • Kubernetes Custom Resource Definitions
          • cluster.redpanda.com/v1alpha2
      • Monitoring Metrics
        • Public Metrics
        • Internal Metrics
      • rpk Commands
        • rpk
        • rpk -X
        • rpk cluster
          • rpk cluster config
            • rpk cluster config edit
            • rpk cluster config export
            • rpk cluster config force-reset
            • rpk cluster config get
            • rpk cluster config import
            • rpk cluster config list
            • rpk cluster config lint
            • rpk cluster config set
            • rpk cluster config status
          • rpk cluster connections
            • rpk cluster connections list
          • rpk cluster health
          • rpk cluster license
            • rpk cluster license info
            • rpk cluster license set
          • rpk cluster logdirs
            • rpk cluster logdirs describe
          • rpk cluster maintenance
            • rpk cluster maintenance disable
            • rpk cluster maintenance enable
            • rpk cluster maintenance status
          • rpk cluster info
          • rpk cluster partitions
            • rpk cluster partitions balance
            • rpk cluster partitions disable
            • rpk cluster partitions enable
            • rpk cluster partitions list
            • rpk cluster partitions balancer-status
            • rpk cluster partitions move
              • rpk cluster partitions move-cancel
              • rpk cluster partitions move-status
            • rpk cluster partitions transfer-leadership
            • rpk cluster partitions unsafe-recover
          • rpk cluster quotas
            • rpk cluster quotas alter
            • rpk cluster quotas describe
            • rpk cluster quotas import
          • rpk cluster self-test
            • rpk cluster self-test start
            • rpk cluster self-test status
            • rpk cluster self-test stop
          • rpk cluster storage
            • rpk cluster storage mount/unmount
              • rpk cluster storage cancel mount
              • rpk cluster storage list mount
              • rpk cluster storage list-mountable
              • rpk cluster storage mount
              • rpk cluster storage status mount
              • rpk cluster storage unmount
            • rpk cluster storage restore
            • rpk cluster storage restore start
            • rpk cluster storage restore status
          • rpk cluster txn
            • rpk cluster txn describe
            • rpk cluster txn describe-producers
            • rpk cluster txn list
        • rpk connect
          • rpk connect blobl server
          • rpk connect create
          • rpk connect echo
          • rpk connect install
          • rpk connect lint
          • rpk connect list
          • rpk connect run
          • rpk connect streams
          • rpk connect studio pull
          • rpk connect studio sync-schema
          • rpk connect template lint
          • rpk connect test
          • rpk connect uninstall
          • rpk connect upgrade
          • rpk connect mcp-server
            • rpk connect mcp-server init
            • rpk connect mcp-server lint
        • rpk container
          • rpk container
          • rpk container purge
          • rpk container start
          • rpk container status
          • rpk container stop
        • rpk debug
          • rpk debug bundle
          • rpk debug remote-bundle cancel
          • rpk debug remote-bundle download
          • rpk debug remote-bundle start
          • rpk debug remote-bundle status
          • rpk debug remote-bundle
        • rpk generate
          • rpk generate app
          • rpk generate grafana-dashboard
          • rpk generate license
          • rpk generate prometheus-config
          • rpk generate shell-completion
        • rpk group
          • rpk group delete
          • rpk group offset-delete
          • rpk group describe
          • rpk group list
          • rpk group seek
        • rpk help
        • rpk iotune
        • rpk plugin
          • rpk plugin list
          • rpk plugin uninstall
          • rpk plugin install
        • rpk profile
          • rpk profile clear
          • rpk profile create
          • rpk profile current
          • rpk profile delete
          • rpk profile edit
          • rpk profile edit-globals
          • rpk profile list
          • rpk profile print
          • rpk profile print-globals
          • rpk profile prompt
          • rpk profile rename-to
          • rpk profile set
          • rpk profile set-globals
          • rpk profile use
        • rpk registry
          • rpk registry compatibility-level
            • rpk registry compatibility-level get
            • rpk registry compatibility-level set
          • rpk registry mode
            • rpk registry mode get
            • rpk registry mode reset
            • rpk registry mode set
          • rpk registry schema
            • rpk registry schema check-compatibility
            • rpk registry schema create
            • rpk registry schema delete
            • rpk registry schema get
            • rpk registry schema list
            • rpk registry schema references
          • rpk registry subject
            • rpk registry subject delete
            • rpk registry subject list
        • rpk redpanda
          • rpk redpanda admin
            • rpk redpanda admin brokers
              • rpk redpanda admin brokers decommission
              • rpk redpanda admin brokers decommission-status
              • rpk redpanda admin brokers list
              • rpk redpanda admin brokers recommission
            • rpk redpanda admin config
              • rpk redpanda admin config log-level set
              • rpk redpanda admin config log-level
              • rpk redpanda admin config print
            • rpk redpanda config print
            • rpk redpanda admin partitions
              • rpk redpanda admin partitions
              • rpk redpanda admin partitions list
          • rpk redpanda check
          • rpk redpanda config
            • rpk redpanda config bootstrap
            • rpk redpanda config init
            • rpk redpanda config set
          • rpk redpanda mode
          • rpk redpanda start
          • rpk redpanda stop
          • rpk redpanda tune
            • rpk redpanda tune
            • rpk redpanda tune help
            • rpk redpanda tune list
        • rpk security
          • rpk security acl
            • rpk security acl create
            • rpk security acl delete
            • rpk security acl list
          • rpk security role
            • rpk security role assign
            • rpk security role create
            • rpk security role delete
            • rpk security role describe
            • rpk security role list
            • rpk security role unassign
          • rpk security user
            • rpk security user create
            • rpk security user delete
            • rpk security user update
            • rpk security user list
        • rpk shadow
          • rpk shadow config generate
          • rpk shadow create
          • rpk shadow delete
          • rpk shadow describe
          • rpk shadow failover
          • rpk shadow list
          • rpk shadow status
          • rpk shadow update
        • rpk topic
          • rpk topic add-partitions
          • rpk topic alter-config
          • rpk topic analyze
          • rpk topic consume
          • rpk topic create
          • rpk topic delete
          • rpk topic describe
          • rpk topic describe-storage
          • rpk topic list
          • rpk topic produce
          • rpk topic trim-prefix
        • rpk transform
          • rpk transform build
          • rpk transform delete
          • rpk transform deploy
          • rpk transform init
          • rpk transform list
          • rpk transform logs
          • rpk transform pause
          • rpk transform resume
        • rpk version
      • Glossary
Collapse navigation tree

Collapse

Was this helpful?
🎉 Thanks for your feedback!
  • Docs
  • Self-Managed
  • Get Started
  • How Redpanda Works

How Redpanda Works

At its core, Redpanda is a fault-tolerant transaction log for storing event streams. Producers and consumers interact with Redpanda using the Kafka API. To achieve high scalability, producers and consumers are fully decoupled. Redpanda provides strong guarantees to producers that events are stored durably within the system, and consumers can subscribe to Redpanda and read the events asynchronously.

Redpanda achieves this decoupling by organizing events into topics. Topics represent a logical grouping of events that are written to the same log. A topic can have multiple producers writing events to it and multiple consumers reading events from it.

This page provides details about how Redpanda works. For a high-level overview, see Introduction to Redpanda.

Tiered Storage

Redpanda Tiered Storage is a multi-tiered object storage solution that provides the ability to offload log segments to object storage in near real time. Tiered Storage can be combined with local storage to provide long-term data retention and disaster recovery on a per-topic basis.

Consumers that read from more recent offsets continue to read from local storage, and consumers that read from historical offsets read from object storage, all with the same API. Consumers can read and reread events from any point within the maximum retention period, whether the events reside on local or object storage.

As data in object storage grows, the metadata for it grows. To support efficient long-term data retention, Redpanda splits the metadata in object storage, maintaining metadata of only recently-updated segments in memory or local disk, while safely archiving the remaining metadata in object storage and caching it locally on disk. Archived metadata is then loaded only when historical data is accessed. This allows Tiered Storage to handle partitions of virtually any size or retention length.

For more information, see Tiered Storage.

Partitions

To scale topics, Redpanda shards them into one or more partitions that are distributed across the nodes in a cluster. This allows for concurrent writing and reading from multiple nodes. When producers write to a topic, they route events to one of the topic’s partitions. Events with the same key (like a stock ticker) are always routed to the same partition, and Redpanda guarantees the order of events at the partition level. Consumers read events from a partition in the order that they were written. If a key is not specified, then events are sent to all topic partitions in a round-robin fashion.

Raft consensus algorithm

Redpanda provides strong guarantees for data safety and fault tolerance. Events written to a topic partition are appended to a log file on disk. They can be replicated to other nodes in the cluster and appended to their copies of the log file on disk to prevent data loss in the event of failure. The Raft consensus algorithm is used for data replication.

Every topic partition forms a Raft group consisting of a single elected leader and zero or more followers (as specified by the topic’s replication factor). A Raft group can tolerate ƒ failures given 2ƒ+1 nodes. For example, in a cluster with five nodes and a topic with a replication factor of five, the topic remains fully operational if two nodes fail.

Raft is a majority vote algorithm. For a leader to acknowledge that an event has been committed to a partition, a majority of its replicas must have written that event to their copy of the log. When a majority (quorum) of responses have been received, the leader can make the event available to consumers and acknowledge receipt of the event when acks=all (-1). Producer acknowledgement settings define how producers and leaders communicate their status while transferring data.

As long as the leader and a majority of the replicas are stable, Redpanda can tolerate disturbances in a minority of the replicas. If gray failures cause a minority of replicas to respond slower than normal, then the leader does not have to wait for their responses to progress, and any additional latency is not passed on to the clients. The result is that Redpanda is less sensitive to faults and can deliver predictable performance.

Partition leadership elections

Raft uses a heartbeat mechanism to maintain leader authority and to trigger leader elections. The partition leader sends a periodic heartbeat to all followers to assert its leadership in the current term (default = 150 milliseconds). A term is an arbitrary period of time that starts when a leader election is triggered. If a follower does not receive a heartbeat over a period of time (default = 1.5 seconds), then it triggers an election to choose a new partition leader. The follower increments its term and votes for itself to be the leader for that term. It then sends a vote request to the other nodes and waits for one of the following scenarios:

  • It receives a majority of votes and becomes the leader. Raft guarantees that at most one candidate can be elected the leader for a given term.

  • Another follower establishes itself as the leader. While waiting for votes, the candidate may receive communication from another node in the group claiming to be the leader. The candidate only accepts the claim if its term is greater than or equal to the candidate’s term; otherwise, the communication is rejected and the candidate continues to wait for votes.

  • No leader is elected over a period of time. If multiple followers timeout and become election candidates at the same time, it’s possible that no candidate gets a majority of votes. When this happens, each candidate increments its term and triggers a new election round. Raft uses a random timeout between 150-300 milliseconds to ensure that split votes are rare and resolved quickly.

As long as there is a timing inequality between heartbeat time, election timeout, and mean time between node failures (MTBF), then Raft can elect and maintain a steady leader and make progress. A leader can maintain its position as long as one of the ten heartbeat messages it sends to all of its followers every 1.5 seconds is received; otherwise, a new leader is elected.

If a follower triggers an election, but the incumbent leader subsequently springs back to life and starts sending data again, then it’s too late. As part of the election process, the follower (now an election candidate) incremented the term and rejects requests from the previous term, essentially forcing a leadership change. If a cluster is experiencing wider network infrastructure problems that result in latencies above the heartbeat timeout, then back-to-back election rounds can be triggered. During this period, unstable Raft groups may not be able to form a quorum. This results in partitions rejecting writes, but data previously written to disk is not lost. Redpanda has a Raft-priority implementation that allows the system to settle quickly after network outages.

Controller partition and snapshots

Redpanda stores metadata update commands (such as creating and deleting topics or users) in a system partition called the controller partition. A new snapshot is created after each controller command is added, or, with rapid updates, after a set period of time (default is 60 seconds). Controller snapshots save the current cluster metadata state to disk, so startup is fast. For example, with a partition that has moved several times, a snapshot can restore the latest state without replaying every move command.

Each broker has a snapshot file stored in the controller log directory, such as /var/lib/redpanda/data/redpanda/controller/0_0/snapshot. The controller partition is replicated by a Raft group that includes all cluster brokers, and the controller snapshot is the Raft snapshot for this group. Snapshots are hydrated when a broker joins the cluster or restarts. Snapshots are enabled by default for all clusters, both new and upgraded.

Optimized platform performance

Redpanda is designed to exploit advances in modern hardware, from the network down to the disks. Network bandwidth has increased considerably, especially in object storage, and spinning disks have been replaced by SSD devices that deliver better I/O performance. CPUs are faster too, but this is largely due to the increased core counts as opposed to the increase in single-core speeds. Redpanda has tuners that detect your hardware configuration to automatically optimize itself.

Examples of platform and kernel features that Redpanda uses to optimize its performance:

  • Direct Memory Access (DMA) for disk I/O

  • Sparse file system support with XFS

  • Distribution of interrupt request (IRQ) processing between CPU cores

  • Isolated processes with control groups (cgroups)

  • Disabled CPU power-saving modes

  • Upfront memory allocation, partitioned and pinned to CPU cores

Thread-per-core model

Redpanda implements a thread-per-core programming model through its use of the Seastar library. This allows Redpanda to pin each of its application threads to a CPU core to avoid context switching and blocking. It combines this with structured message passing (SMP) to asynchronously communicate between the pinned threads. With this, Redpanda avoids the overhead of context switching and expensive locking operations to improve processing performance and efficiency.

From a sizing perspective, Redpanda’s ability to efficiently use all available hardware enables it to scale up to get the most out of your infrastructure, before you’re forced to scale out to meet the demands of your workload. Redpanda delivers better performance with a smaller footprint, resulting in reduced operational costs and complexity.

Next steps

Try out Redpanda, or learn about Redpanda Licensing.

Suggested reading

  • A developer’s guide to Redpanda

  • How Redpanda’s cloud-first storage model reduces TCO

  • Thread-per-core buffer management for a modern Kafka-API storage system

Suggested videos

  • YouTube - Lightning Talk: Tiered Storage (11:39 mins)

  • YouTube - Intro to Redpanda: Thread-per-core architecture in C++ (60 mins)

  • YouTube - Differences between Apache Kafka and Redpanda: Thread per Core Architecture (4:30 mins)

  • YouTube - Common pitfalls for Redpanda beginners (44:35 mins)

Back to top
×

Simple online edits

For simple changes, such as fixing a typo, you can edit the content directly on GitHub.

Edit on GitHub

Or, open an issue to let us know about something that you want us to change.

Open an issue

Contribution guide

For extensive content updates, or if you prefer to work locally, read our contribution guide .

Was this helpful?
group Ask in the community
mail Share your feedback
group_add Make a contribution
🎉 Thanks for your feedback!
Introduction to Redpanda Introduction to Redpanda Console
Image for tracking purposes only
Redpanda
Product
Agentic Data Plane Data Streaming
Learn
Resources Events On-demand Blog
Company
About us Customers Press Partners Careers Contact Legal hub Trust center
Privacy policy
© 2026 Redpanda. All rights reserved.
`; /** * For API endpoint results we show a tiny example to reduce clicks. * This is pure UI enrichment: not required by Algolia. */ const hasEndpoint = !!(preview && (preview.method || preview.path)); let endpointLine = ''; let curlExample = ''; if (hasEndpoint) { const method = (preview.method || 'GET').toUpperCase(); const path = preview.path || ''; endpointLine = `${method} ${path}`; let origin = ''; try { origin = new URL(preview.url || '').origin; } catch (e) { /* no-op */ } curlExample = `curl -X ${method} '${origin ? origin + path : path}'`; } // Integrate AI assistant with the current query. const askAIButton = currentQuery ? html`` : ''; // Compose a “View all results” link that respects product + version context. const componentTitle = 'Self-Managed'; const productParams = (() => { if (componentTitle === 'Cloud') return '&product[0]=Cloud&product[1]=Connect'; if (componentTitle === 'Self-Managed') return '&product[0]=Self-Managed&product[1]=Connect'; return ''; })(); const viewAllLink = currentQuery ? html` View all results ` : ''; // Layout: header (filters/AI), results list, right-side preview, footer tips. render( html`
${dropdown} ${askAIButton}
${children}
${ preview ? html`
${ preview.breadcrumbs ? html`
    ${preview.breadcrumbs.map( (breadcrumb) => html`
  • { event.stopPropagation(); // Click analytics requires clickAnalytics: true and a queryID. // Docs: https://www.algolia.com/doc/api-reference/api-parameters/clickAnalytics/ aa('clickedObjectIDsAfterSearch', { eventName: 'Preview Selected', index: state.context.preview.__autocomplete_indexName, queryID: state.context.preview.__autocomplete_queryID, objectIDs: [state.context.preview.objectID], positions: [state.activeItemId + 1], // positions start at 1 }); }} href="${breadcrumb.u}" > ${breadcrumb.t}
  • ` )}
` : '' }

${components.Highlight({ hit: preview, attribute: 'title' })}

${ preview.intro ? components.Highlight({ hit: preview, attribute: 'intro' }) : preview.description ? components.Highlight({ hit: preview, attribute: 'description' }) : '' }

${ preview.api ? html`
${preview.api}
` : '' } ${ hasEndpoint ? html`

Endpoint

${endpointLine}

Example

${curlExample}
` : '' } ${ preview.image ? html`
${ SUPPORTED_PREVIEW_TYPES.includes((preview.type || '').toLowerCase()) ? html` { event.stopPropagation(); aa('clickedObjectIDsAfterSearch', { eventName: 'Preview Selected', index: state.context.preview.__autocomplete_indexName, queryID: state.context.preview.__autocomplete_queryID, objectIDs: [state.context.preview.objectID], positions: [state.activeItemId + 1], }); }} href="${preview.url || preview.objectID}" > ${preview.title || ''} ` : html` { event.stopPropagation(); aa('clickedObjectIDsAfterSearch', { eventName: 'Preview Selected', index: state.context.preview.__autocomplete_indexName, queryID: state.context.preview.__autocomplete_queryID, objectIDs: [state.context.preview.objectID], positions: [state.activeItemId + 1], }); }} target="_blank" rel="noopener noreferrer" href="${preview.url || preview.objectID}" > ${preview.title || ''} ` }
` : '' }
${preview.titles && preview.titles.length > 0 ? html`

On this page

` : ''}
    ${(preview.titles || []).slice(0, 15).map( (title) => html`
  • ${ SUPPORTED_PREVIEW_TYPES.includes((state.context.preview.type || '').toLowerCase()) ? html` { event.stopPropagation(); aa('clickedObjectIDsAfterSearch', { eventName: 'Preview Selected', index: state.context.preview.__autocomplete_indexName, queryID: state.context.preview.__autocomplete_queryID, objectIDs: [state.context.preview.objectID], positions: [state.activeItemId + 1], }); }} href="${(preview.url || preview.objectID)}#${title.h}" > ${components.Highlight({ hit: title, attribute: 't' })} ` : html` { event.stopPropagation(); aa('clickedObjectIDsAfterSearch', { eventName: 'Preview Selected', index: state.context.preview.__autocomplete_indexName, queryID: state.context.preview.__autocomplete_queryID, objectIDs: [state.context.preview.objectID], positions: [state.activeItemId + 1], }); }} target="_blank" rel="noopener noreferrer" href="${(preview.url || preview.objectID)}#${title.h}" > ${components.Highlight({ hit: title, attribute: 't' })} ` }
  • ` )}
  • ⏎to select
  • ↓↑to navigate
  • Escto close
${viewAllLink}
` : '' }
`, root ); }, /** * Define our data sources: * - "filters": facet values for the _tags facet (used by the tags plugin) * - "docs": actual content/hits * Sources overview: https://www.algolia.com/doc/ui-libraries/autocomplete/core-concepts/sources/ */ getSources({ query, state }) { const tagsByFacet = groupBy(state.context.tagsPlugin.tags, (tag) => tag.facet); return [ { sourceId: 'filters', getItems() { // Fetch facet values for _tags to populate the checkbox menu. // getAlgoliaFacets: https://www.algolia.com/doc/ui-libraries/autocomplete/api-reference/sources/#param-getalgoliafacets return getAlgoliaFacets({ searchClient, queries: [ { indexName: 'redpanda', facet: '_tags', params: { facetQuery: '', // https://www.algolia.com/doc/api-reference/api-parameters/facetQuery/ maxFacetHits: 50, // https://www.algolia.com/doc/api-reference/api-parameters/maxFacetHits/ }, }, ], transformResponse({ facetHits }) { // We return raw server facets; union with known+selected happens in render(). const server = (facetHits[0] || []).map(h => ({ label: h.label, facet: '_tags' })); return server; }, }); }, templates: { header() { return null; }, item() { return null; }, }, }, { sourceId: 'docs', getItems() { // getAlgoliaResults: https://www.algolia.com/doc/ui-libraries/autocomplete/api-reference/sources/#param-getalgoliaresults return getAlgoliaResults({ searchClient, queries: [ { indexName: 'redpanda', query, params: { clickAnalytics: true, // https://www.algolia.com/doc/api-reference/api-parameters/clickAnalytics/ hitsPerPage: 10, // https://www.algolia.com/doc/api-reference/api-parameters/hitsPerPage/ attributesToSnippet: ['*:25'], // https://www.algolia.com/doc/api-reference/api-parameters/attributesToSnippet/ snippetEllipsisText: '…', // https://www.algolia.com/doc/api-reference/api-parameters/snippetEllipsisText/ tagFilters: mapToAlgoliaFilters(tagsByFacet), // https://www.algolia.com/doc/api-reference/api-parameters/tagFilters/ }, }, ], transformResponse({ hits }) { // Re-order mixed hits so Docs stay in place while non-Doc items // are time-sorted, and compute a matchingHeading to deep-link // to the best title match. return hits.map((nestedHits) => { const docIndices = new Map(); nestedHits.forEach((item, index) => { if (item.type === 'Doc') { docIndices.set(index, item); } }); const nonDocItems = nestedHits .filter((item) => item.type !== 'Doc') .sort((a, b) => (b.unixTimestamp ?? -Infinity) - (a.unixTimestamp ?? -Infinity)); let nonDocIndex = 0; docIndices.forEach((item, index) => { if (item._highlightResult && item._highlightResult.titles) { const matchedIndex = item._highlightResult.titles.findIndex( (title) => title.t.matchLevel === 'full' ); if (matchedIndex !== -1) { const matchedTopLevelTitle = item.titles[matchedIndex]; if (matchedTopLevelTitle) { item.matchingHeading = `#${matchedTopLevelTitle.h}`; } } } nestedHits[index] = item; }); return nestedHits.map((item, index) => docIndices.has(index) ? docIndices.get(index) : nonDocItems[nonDocIndex++] ); }); }, }); }, templates: { noResults({ state, html }) { // Clear preview so we don’t show stale content for a query with no hits. state.context.preview = null; if (!state.query) return; return html`
No results for ${state.query}

Believe this query should return results? Let us know .

`; }, header({ items, html }) { if (!items.length) return; return html` Results
`; }, item({ item, components, html }) { const matchingHeading = item.matchingHeading || ''; // Helper: render “product” as deduped badges const renderProduct = (product) => { if (Array.isArray(product)) { const seen = new Set(); return product .filter(p => { const k = (p || '').toLowerCase(); if (seen.has(k)) return false; seen.add(k); return true; }) .map(p => html`
${p}
`); } else if (product) { return html`
${product}
`; } return null; }; // If previewable, navigate within the panel; otherwise open a new tab. const aTag = SUPPORTED_PREVIEW_TYPES.includes((item.type || '').toLowerCase()) ? html`
${components.Highlight({ hit: item, attribute: 'title' })}
${ item.text ? html`
${ item.text ? components.Snippet({ hit: item, attribute: 'text' }) : item.intro ? components.Snippet({ hit: item, attribute: 'intro' }) : item.description ? components.Snippet({ hit: item, attribute: 'description' }) : '' }
` : html`
${ item.intro ? components.Snippet({ hit: item, attribute: 'intro' }) : item.description ? components.Snippet({ hit: item, attribute: 'description' }) : '' }
` }
${item.type}
${renderProduct(item.product)} ${item.api ? html`
${item.api}
` : ''} ${item.version ? html`
${item.version}
` : ''}
` : html`
${components.Highlight({ hit: item, attribute: 'title' })}
${ item.breadcrumbs ? html`
    ${ item.breadcrumbs.length > 2 && item.breadcrumbs .slice(1, item.breadcrumbs.length - 1) .map((breadcrumb) => html`
  • ${breadcrumb.t}
  • `) } ${ item.breadcrumbs.length === 2 && item.breadcrumbs.slice(1).map((breadcrumb) => html`
  • ${breadcrumb.t}
  • `) }
` : '' }
${ item.text ? components.Snippet({ hit: item, attribute: 'text' }) : item.intro ? components.Snippet({ hit: item, attribute: 'intro' }) : item.description ? components.Snippet({ hit: item, attribute: 'description' }) : '' }
${item.type}
${renderProduct(item.product)} ${item.version ? html`
${item.version}
` : ''}
`; return html`${aTag}`; }, }, getItemUrl({ item }) { return item.url || item.objectID; }, onActive({ item, setContext, state }) { const ctx = state?.context || {}; setContext({ ...ctx, preview: item }); }, } ]; }, }); /** * Expose the Autocomplete instance globally so other UI (our custom dropdown) * can drive its context without capturing stale references across re-renders. * This is intentionally namespaced and “private”. See notes below. */ window.__algoliaAutocompleteInstance = autocompleteInstance; } window.addEventListener('DOMContentLoaded', initAlgolia);
Expand navigation tree