Skip to main content

Data model

Each document has an id and text (plus optional metadata). Use moss-minilm as the default model.

Examples

From JSON or TXT files

JSON and text files don’t need server-side parsing: read them in your code and pass the contents to createIndex / create_index or addDocs / add_docs as documents. A JSON array of {id, text, metadata} records maps one to one; metadata values must be strings (Python 1.18.0+ converts numbers and booleans in dict and JSON input, see below). Split text files into passages (see Chunking tips) rather than indexing a whole file as one document. In Python, create_index and add_docs can also take the JSON or the file itself, and can chunk text for you; see Python: JSON, JSON Lines and files.

Python: JSON, JSON Lines and files

In Python, create_index, add_docs and SessionIndex.add_docs take JSON, dicts and file paths directly, so the code above is optional. (moss 1.18.0+)
  • A str is always read as JSON text, so wrap file paths in pathlib.Path. Supported files are .json, .jsonl, .ndjson, .txt, .md and .markdown; use create_index_from_files for PDF and DOCX.
  • Each JSON record has an id and text, plus optional metadata, embedding and payload. Integer ids become strings, and number and boolean metadata values are stored as strings: booleans as "true" and "false".
  • Chunks of a .txt or .md file get the ids {path}#{n} and the metadata parentId. Markdown chunks start with their heading path, such as Returns > Refunds, and front matter is not indexed. Pass relative paths for stable ids.
  • Re-ingesting a file that now has fewer chunks leaves its old higher-numbered chunks in the index; remove them with delete_docs. A document’s payload is copied onto every chunk.
Pass chunking= to tune the native chunker. With it, DocumentInfo, dict and JSON input is chunked too, which is how you split documents that you add yourself:
Pass chunker= instead to split the text yourself. It is a synchronous function from a document’s text to a list of chunk strings, it runs for every document, files included, and each chunk may have at most 2,000 characters. Pass chunker or chunking, not both, and neither with model_id="custom".
See Chunking for the limits, defaults and errors.

From files (PDF and DOCX)

Build an index directly from raw documents - the server parses, chunks, and embeds them. Up to 20 files per call, 50 MB per file. Parsed document pages count against your plan’s monthly allowance; see Pricing & Limits. When the allowance is used up on a plan without overage billing, createIndexFromFiles fails with 429 USAGE_LIMIT_EXCEEDED at init or at confirm; a denial at confirm marks the job failed. PDF pages are counted before parsing. A PDF that cannot be page-counted before parsing (larger than 10 MB, unreadable, or past the page-counting budget of 200 MB or 20 seconds per request) is also denied on those plans. A confirm denied because your organization is running its maximum number of crawl and parse jobs leaves the job open: retry the confirm once a job finishes.
See Index from files for parse options, limits, and querying notes.

From a website

Register a site as a web source and Moss crawls it into an index - optionally on a daily or weekly refresh schedule (scheduled refresh requires the Startup plan or above; omit refreshCadence on Developer and Hobbyist and re-sync manually on Hobbyist). Linked PDF and DOCX files found during the crawl are parsed into the same index. An index can hold up to 20 web sources. Each site is crawled and refreshed on its own, and a crawl only replaces that source’s pages, so several sites can share one index together with documents you add directly. The first source creates the index; later ones add to it, and a crawl requested while another is running on the index simply queues behind it.
See Web Sources for the JavaScript SDK, Web Sources for Python, and Create Web Source for crawl limits, scheduling, and the full set of web source actions.

Local-first indexing (sessions)

createIndex / create_index builds an index through the cloud (then keeps it usable locally). When you need to index during a live interaction - adding transcript turns mid-call or building a per-user working set - use a session instead. A session indexes documents locally in real time with no cloud round trip, embedding each document on-device, and lets you optionally push the result to the cloud when you’re done.
See Sessions for the full create-resume-query-push lifecycle.

Notes

  • createIndex / create_index will sync indexes to cloud (if enabled) while remaining usable locally
  • Supports multiple indexes per project; pick the model per index:
    • moss-minilm: fast, lightweight (default)
    • moss-mediumlm: higher accuracy, still efficient
    • Use moss-minilm for speed-first, edge/offline use; use moss-mediumlm when you need higher recall/precision

Chunking tips

Uploaded files and web sources are chunked automatically; see Files (JavaScript, Python). Documents you add yourself are indexed as given, so split them first. In Python, chunking= and chunker= can do that for you, and .txt and .md files are chunked by default (see Python: JSON, JSON Lines and files). If you split documents yourself:
  • Keep chunks under about 1200 characters, cut at sentence boundaries, overlapping by about 200 characters
  • Start each chunk with the document title so a hit identifies its source
  • Normalize whitespace and strip boilerplate