create_index_from_files builds a new index directly from raw documents. You upload PDF and
DOCX files; the server parses them, splits them into chunks, generates embeddings, and builds
the index. The call returns when the index is ready to query.
Requires
moss 1.7.3+. Also available in JavaScript as
createIndexFromFiles (@moss-js/moss 1.8.0+). chunk_size and chunk_overlap need 1.17.0+ (JavaScript 1.18.0+).How it works
The call handles the full flow: it registers the files, uploads each one, and triggers parsing, embedding, and the index build server-side. It blocks until the index is ready and returns aMutationResult. Jobs time out after 30 minutes.
There is no progress callback in Python.
Files
Each entry is aParseFileInput:
Limits:
- 1 to 20 files per call. Each call creates a new index, and files cannot be appended to an existing index afterwards, so an index is built from at most 20 files.
- 50 MB per file, enforced server-side. The SDK does not pre-check size; an oversized file fails during the job.
Options
- model_id (
Optional[str]=None) - defaults to"moss-minilm";"moss-mediumlm"is also supported."custom"is not supported - the server generates embeddings during parsing. - parse_options (Optional[
ParseOptions] =None) - extraction controls, below.
Parse options
All fields ofParseOptions are optional; omitted fields use
the server defaults.
The extraction options shape the text the parser extracts; chunking then runs over it as one stream per file.
What gets indexed
Documents are split into chunks of up tochunk_size characters overlapping by up to chunk_overlap,
each prefixed with a title (the document’s title or first heading, else the file name) that
is part of the hit text returned by query. Repeating page
headers, footers, page numbers, and images are excluded from the indexed text.
A scanned or
image-only document produces no readable text unless OCR runs - if a file fails with
“No readable text was found”, retry with parse_options=ParseOptions(ocr_mode="full_ocr").
Querying a parse-built index
Query the index without loading it -client.query(name, text) runs server-side when the
index is not loaded locally:
Errors
Passingmodel_id="custom" raises ValueError before anything is uploaded. Other failures
raise MossError; str(e) is fixed text, e.detail starts with: