Skip to content

Meilisearch

Keep index(uid).search() and the familiar hit and pagination envelopes. Native HTTP clients can point their host at /compat/meilisearch.

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 { createDocSlurpMeilisearchClient } from '@docslurp/sdk/search-adapters';
Terminal
# Same client as @docslurp/sdk/search-adapters, one subpath per search client.
npm install @docslurp/contrib-search-compat

# Then import:
# import { createDocSlurpMeilisearchClient } from '@docslurp/contrib-search-compat/meilisearch';

2Swap the client

Index UIDs become workspace references: a slug like product-docs, a UUID, or default for your organization’s default workspace.

search.tsDiff
- import { MeiliSearch } from 'meilisearch';
- const client = new MeiliSearch({ host: MEILI_HOST, apiKey: MEILI_SEARCH_KEY });
+ import { createDocSlurpMeilisearchClient } from '@docslurp/sdk/search-adapters';
+ const client = createDocSlurpMeilisearchClient({
+   apiUrl: 'https://docslurp.io',
+   clientKey: PUBLIC_DOCSLURP_CLIENT_KEY,
+ });

  // Unchanged: index(uid).search(q, params)
  const result = await client.index('product-docs').search('installation', { limit: 10 });

3Usage

search.ts
import { createDocSlurpMeilisearchClient } from '@docslurp/sdk/search-adapters';

const client = createDocSlurpMeilisearchClient({ apiUrl: 'https://docslurp.io', clientKey });
const index = client.index('product-docs'); // or 'default'

// Offset pagination…
const page1 = await index.search('installation', { offset: 0, limit: 10 });
// …or numbered pages
const page2 = await index.search('installation', { page: 2, hitsPerPage: 10 });

page1.hits.map(hit => hit.title); // id, text, title, filename, url, score, citation
Terminal
curl https://docslurp.io/compat/meilisearch/indexes/product-docs/search \
  -H "Authorization: Bearer $DOCSLURP_SEARCH_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "q": "installation", "limit": 10 }'
search.ts
// Any Meilisearch HTTP client: point its host at the compat origin.
const response = await fetch('https://docslurp.io/compat/meilisearch/indexes/product-docs/search?q=installation&limit=10', {
  headers: { Authorization: `Bearer ${DOCSLURP_SEARCH_KEY}` },
});

GET and POST both work. The default page size is 20.

Response

Hits keep Meilisearch’s envelope. DocSlurp adds a docslurp object with the retrieval window, workspace availability, session ID and usage.

200 OKJSON
{
  "hits": [
    {
      "id": "8f1c…:12",
      "text": "Install the CLI with npm, then set DOCSLURP_API_KEY.",
      "title": "install-guide.pdf",
      "filename": "install-guide.pdf",
      "url": "",
      "score": 0.83,
      "citation": { "documentId": "8f1c…", "filename": "install-guide.pdf", "pageNumbers": [3], "chunkIndex": 12 }
    }
  ],
  "query": "installation",
  "processingTimeMs": 142,
  "offset": 0,
  "limit": 10,
  "estimatedTotalHits": 37,
  "docslurp": {
    "bounded": true,
    "windowLimit": 100,
    "countIsExact": false,
    "sessionId": "…",
    "availability": { "status": "complete" },
    "usage": { "inputTokens": 6, "costCents": 0.0001 }
  }
}

Compatibility

Supported

  • GET and POST /indexes/:uid/search with bearer auth
  • q, offset/limit or page/hitsPerPage
  • Hits with id, text, title, filename, url, score, citation

Watch for

  • filter, sort, facets and arbitrary attributes return HTTP 400.
  • Pages past the first 100 passages return 400; narrow the query instead.
  • Multi-search and index, document or settings APIs are not emulated. Ingest through DocSlurp.

Hand off to an agent

Working in a real codebase? Copy a prompt that tells a coding agent exactly what to change for Meilisearch: 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