Data model
Each document has anid 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 tocreateIndex / 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
stris always read as JSON text, so wrap file paths inpathlib.Path. Supported files are.json,.jsonl,.ndjson,.txt,.mdand.markdown; usecreate_index_from_filesfor PDF and DOCX. - Each JSON record has an
idandtext, plus optionalmetadata,embeddingandpayload. Integer ids become strings, and number and boolean metadata values are stored as strings: booleans as"true"and"false". - Chunks of a
.txtor.mdfile get the ids{path}#{n}and the metadataparentId. Markdown chunks start with their heading path, such asReturns > 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’spayloadis copied onto every chunk.
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:
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".
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.
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; omitrefreshCadence 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.
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.
Notes
createIndex/create_indexwill 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-minilmfor speed-first, edge/offline use; usemoss-mediumlmwhen 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