Todd Tarsi
04/16/2025, 2:16 PMFanis Tharropoulos
04/16/2025, 2:18 PMTodd Tarsi
04/16/2025, 2:19 PMFanis Tharropoulos
04/16/2025, 2:20 PMTodd Tarsi
04/16/2025, 2:21 PMwhile (true) {
const searchResults = await client
.collections<{id: number | string}>(COLLECTION_NAME)
.documents()
.search({
q: '*',
query_by: 'id', // or another indexed field
page,
per_page: perPage,
});
if (!searchResults || !searchResults.hits) {
console.error('Failed to retrieve search results:', searchResults);
break;
}
console.log(`Processing page ${page}...`);
if (searchResults.hits.length === 0) {
break;
}
await client
.collections(COLLECTION_NAME)
.documents()
.import(
searchResults.hits.map(h => ({
id: h.document.id,
[FIELD_TO_DROP]: null,
})),
{
action: 'update',
}
);
if (searchResults.hits.length < perPage) {
break;
}
page++;
}
Fanis Tharropoulos
04/16/2025, 2:22 PMFanis Tharropoulos
04/16/2025, 2:22 PMTodd Tarsi
04/16/2025, 2:23 PMTIP
Dropping a field affects only the schema and the in-memory index; it does not remove the data associated with that field from the existing documents stored on disk. In Typesense, documents can contain additional fields not explicitly defined in the schema.
To permanently remove a field and its data from a document, you must update the document directly, by passing null to the field you want to remove.
Maybe there’s something I’m misunderstanding about how ram is consumed. These fields aren’t faceted. Do they perhaps only consume disk space and not ram?Fanis Tharropoulos
04/16/2025, 2:25 PMTodd Tarsi
04/16/2025, 2:26 PMFanis Tharropoulos
04/16/2025, 2:29 PM