Same Filename, Different File
Two uploaded files can now have the same filename and be two documents.
Before, the filename was the document. With the default settings, a second report.txt was skipped even when its content was different, and the old content stayed. Now Captain compares the content of the two files. A report.txt with different content is added as a new document. Both are listed as report.txt, each with its own document_id and its own content.
A file with the same filename and the same content is still skipped, so sending a request again does not add copies.
This applies to files sent through Index File.
Do I need to change anything?
- If you upload with the default settings and expect a changed file to be skipped: it is now added as a second document. To update the existing document, upload the changed file with
skip_existing=false. - If you replace files with
skip_existing=false: nothing changes while one document has that filename. It keeps itsdocument_idand gets a newversion_id. If several documents have the filename, the request now returns a409that lists theirdocument_idvalues. Sendreplace_document_idsto say which one to replace. - If you look a document up by its filename: a filename can now match more than one document. Use
document_idto tell them apart.
Replace one document by its ID
replace_document_ids is a new field on Index File. It is a JSON array sent as a string, with one entry per file in the order the files are sent: the document_id the file replaces, or null. It needs skip_existing=false.
curl -X POST "https://api.filesearch.dev/v2/collections/my_documents/index/file" \
-H "Authorization: Bearer your_api_key" \
-F "files=@report.txt" \
-F "skip_existing=false" \
-F 'replace_document_ids=["9f3c1d0e5a7b4c2d8e6f0a1b2c3d4e5f"]'Good to know
- The check for a file that is already indexed sees finished and running uploads, not requests that arrive at the same moment. If you send the same new file in two requests at once, both can be added. To retry a request safely, send the same
Idempotency-Key, or wait for the first job to finish. - The v3 listing's
checksumfield is now set for new uploads:sha256:followed by the hex SHA-256 of the file's bytes. It stays null for earlier uploads. An email file (.emlor.msg) is indexed as its body and attachments. Each of those listsetag:followed by a storage hash of that part, not a SHA-256. - Files uploaded before today have no stored hash. For those, Captain compares the stored file itself: its size first, then a storage checksum. When many such files share a filename, it compares the new file with at most 20 of them.
- On a deployment without zero-downtime replace, replacing a document in place needs
overwrite_existing=truetogether withskip_existing=false. The hosted API has zero-downtime replace, so nothing changes there. - A file uploaded through the dashboard before it started adding a name token to stored files now counts as the same filename for an API upload. The same content is skipped, different content is added as a new document, and
skip_existing=falsereplaces that document in place. Before, the API upload was always a second document. - A file from an older request that sent two files with one filename may be listed without a document record of its own. It stays searchable and can be deleted. Naming it in
replace_document_idsreturns a400: delete it and upload the file again. It is not compared when a file with its name is uploaded, so sending its exact content again adds one copy, once.
What stays the same
- Documents that are already indexed keep their
document_id, their filename and their content. They follow the new rules from now on. - Two files sent with the same filename in one request are two documents, as before.
- Files indexed from a bucket or another connector do not change.