#community-help

Adding ID Field to Index and Schema Retrospectively

TLDR Zach asked about adding an ID field in the schema without altering existing documents. Jason suggested creating a new field called id_search for this purpose.

Powered by Struct AI
white_check_mark1
2
3mo
Solved
Join the chat
Jun 07, 2023 (3 months ago)
Zach
Photo of md5-dc5b28803821182bb4a305a56f9baf4e
Zach
12:14 AM
Hi team, quick question, in my collections i have not previously added the id in the schema as I have seen the documents are assigned my firebase doc IDs (using the firebase extension for sync). Is it possible to add the id field to the index and schema retrospectively, without adding it to the documents as a separate field value? Realised it would be useful to be able to search for document IDs.. WHen trying to add the field to the schema I get
Error: e: Request failed with HTTP code 400 | Server said: Field `id` cannot be altered.

Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
12:19 AM
id is a special field in Typesense and we don’t allow searching on it directly. So you would have to create a new field called say id_search and then store the ID there and use that for search
white_check_mark1