Skip to main content

Problem

You need sub-10 ms retrieval and instant index updates without heavy infrastructure.

Architecture

  • Index once; query in sub-10 ms
  • Optional background sync to cloud
  • Query pipeline: text -> embed -> retrieve -> rerank (optional)

Prerequisites

  • Node.js 16+ or Python 3.8+
  • Moss credentials: MOSS_PROJECT_ID, MOSS_PROJECT_KEY
  • An index to query (create faqs via the Quickstart if you don’t have one yet)

Steps

  1. Export credentials (and index if different):
export MOSS_PROJECT_ID=your_project_id
export MOSS_PROJECT_KEY=your_project_key
export MOSS_INDEX_NAME=faqs   # or your index
  1. Ensure the index exists (see Quickstart to create faqs).
  2. Run one of the snippets below.

Run the sample (JavaScript or Python)

import { MossClient } from '@inferedge/moss'

const client = new MossClient(
  process.env.MOSS_PROJECT_ID!,
  process.env.MOSS_PROJECT_KEY!
)

const indexName = process.env.MOSS_INDEX_NAME || 'faqs' // ensure this exists (see Quickstart)

async function main() {
  await client.loadIndex(indexName)
  const results = await client.query(indexName, 'How do I return a damaged product?', 3)

  console.log(`Found ${results.docs.length} docs in ${results.timeTakenInMs}ms`)
  results.docs.forEach((doc, i) => {
    console.log(`${i + 1}. [${doc.id}] ${doc.text} (score: ${doc.score.toFixed(3)})`)
  })
}

main().catch(console.error)

Result

Sub-10 ms queries with minimal infra and optional sync. The sample loads your index and returns top matches immediately.