Skip to content

Algolia

Keep InstantSearch and your v4/v5 client calls. The broadest adapter: it also supports a filter subset, facets, highlight tags and migration helpers for settings, synonyms and rules.

Search adapterDeveloper preview@docslurp/sdk/search-adaptersCompare adapters
On this page

1Install

Terminal
# Needs @docslurp/sdk 0.2.0 or newer (0.1.x lacks these exports).
npm install @docslurp/sdk@^0.3.0

# Then import:
# import { createDocSlurpAlgoliaClient } from '@docslurp/sdk/search-adapters';

Migrating settings, synonyms, rules or analytics as well? The Algolia compatibility guide covers the @docslurp/contrib-search-compat/algolia shim and the docslurp import-search-compat migration CLI.

2Swap the client

Replace the Algolia constructor with DocSlurp’s. Use a browser key limited to your allowed websites, and use a workspace slug, UUID or default as the index name.

search-client.tsDiff
- import { liteClient as algoliasearch } from 'algoliasearch/lite';
- const searchClient = algoliasearch(ALGOLIA_APP_ID, ALGOLIA_SEARCH_KEY);
+ import { createDocSlurpAlgoliaClient } from '@docslurp/sdk/search-adapters';
+ const searchClient = createDocSlurpAlgoliaClient({
+   apiUrl: 'https://docslurp.io',
+   clientKey: PUBLIC_DOCSLURP_CLIENT_KEY,
+ });

  // Unchanged: v4 request arrays, v5 { requests }, searchSingleIndex, initIndex().search()
  const { results } = await searchClient.search([
    { indexName: 'product-docs', params: { query: 'leave policy', hitsPerPage: 10 } },
  ]);

3Usage

DocsSearch.tsx
import { InstantSearch, SearchBox, Hits } from 'react-instantsearch';
import { createDocSlurpAlgoliaClient } from '@docslurp/sdk/search-adapters';

const searchClient = createDocSlurpAlgoliaClient({
  apiUrl: 'https://docslurp.io',
  clientKey: import.meta.env.PUBLIC_DOCSLURP_CLIENT_KEY,
});

export function DocsSearch() {
  // indexName is a workspace slug, UUID or "default".
  return (
    <InstantSearch searchClient={searchClient} indexName="product-docs">
      <SearchBox />
      <Hits />
    </InstantSearch>
  );
}
search.ts
import { createDocSlurpAlgoliaClient } from '@docslurp/sdk/search-adapters';

const client = createDocSlurpAlgoliaClient({ apiUrl: 'https://docslurp.io', clientKey });

// v5 style
await client.searchSingleIndex({ indexName: 'product-docs', searchParams: { query: 'leave policy' } });
await client.search({ requests: [{ indexName: 'product-docs', query: 'leave policy' }] });

// v4 style
await client.initIndex('product-docs').search('leave policy', { hitsPerPage: 5 });
Terminal
curl https://docslurp.io/compat/algolia/1/indexes/product-docs/query \
  -H "X-Algolia-API-Key: $DOCSLURP_SEARCH_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "query": "leave policy", "hitsPerPage": 10 }'
Terminal
curl 'https://docslurp.io/compat/algolia/1/indexes/*/queries' \
  -H "X-Algolia-API-Key: $DOCSLURP_SEARCH_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "requests": [
        { "indexName": "product-docs", "query": "leave policy" },
        { "indexName": "default", "query": "leave policy" }
      ] }'

Compatibility

Supported

  • v4 request arrays, v5 { requests }, searchSingleIndex, initIndex().search()
  • Up to 10 requests per batch
  • page and hitsPerPage, up to 1,000 hits
  • A documented filter subset, window-scoped facets, facet search and highlight tags
  • Settings, synonyms, rules and analytics migration helpers

Watch for

  • Filter syntax is a subset of Algolia’s. Test your real filters.
  • Ranking is DocSlurp’s hybrid relevance; custom sort isn’t emulated.
  • Batched requests with an unknown index name return zero hits, not an error.
  • Empty initial queries return zero hits without a network request.

Hand off to an agent

Working in a real codebase? Copy a prompt that tells a coding agent exactly what to change for Algolia: which entry point to use, the supported contract, and what to validate before shipping. It contains no keys or secrets.

Review agent instructions

Before switching traffic, run through the go-live checklist. Stuck? See troubleshooting.

Jump to