Skip to main content
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 a MutationResult. Jobs time out after 30 minutes. There is no progress callback in Python.

Files

Each entry is a ParseFileInput: 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 of ParseOptions 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 to chunk_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

Load the index, then query it like any other index. Queries run in memory, and querying an index that is not loaded raises MossError with code NOT_FOUND:
If a text query on a parse-built index raises InvalidArgumentError, the index records no embedding model version. Keyword-only queries (alpha=0) and queries that pass their own embedding in QueryOptions.embedding still work.

Errors

Passing model_id="custom" raises ValueError before anything is uploaded. Other failures raise MossError; str(e) is fixed text, e.detail starts with: