Skip to content

Feature request: Support type transformation / custom field mapping in Firestore → Typesense extension #131

@pazbl

Description

@pazbl

Feature request: Type transformation / custom field mapping for Firestore → Typesense extension

Hi 👋

I'm using the Firestore → Typesense Firebase extension.

Right now, as far as I can tell, the extension mirrors Firestore fields into Typesense mostly "as-is" – same field names and (effectively) same types, unless I manually preprocess the data before it’s written to Firestore.

My use case

In Firestore I have a field that is stored as a stringified JSON (for example, an EditorJS-like content object):

{
  "postContent": "{\"time\":1764967717268,\"blocks\":[{\"id\":\"...\",\"type\":\"paragraph\",\"data\":{\"text\":\"...\"}}],\"version\":\"2.31.0\"}"
}

In Typesense I would like this field to be stored as a structured object (or at least as a different type / transformed format), e.g.:

{
  "postContent": {
    "time": 1764967717268,
    "blocks": [ ... ],
    "version": "2.31.0"
  }
}

More generally, I'd like to be able to:

Parse JSON strings from Firestore into objects before indexing in Typesense

Convert Firestore types into different Typesense types (e.g. string → object, string → int, etc.)

Do this without having to change how data is stored in Firestore itself (because Firestore structure is already used by other parts of the app)

Problem today:
From what I see, the extension does not provide an easy way to:

Define a per-field mapping like:
postContent (Firestore string) → postContent (Typesense object parsed from JSON)

Register a small transform function/hook that runs on the document payload before it's sent to Typesense

So the only options right now are:

Change how the data is stored in Firestore (not always possible / desirable), or

Build a custom sync pipeline instead of using the extension.

What I’m asking for
It would be very helpful if the extension supported something like:

A field mapping / type transformation config, e.g.:

{
  "mappings": {
    "postContent": {
      "from": "string",
      "to": "object",
      "transform": "jsonParse"
    }
  }
}

Or, even better, a simple hook API where I can provide a small function that receives the Firestore document and returns the object to be indexed in Typesense, for example:

export function transformForTypesense(doc: any) {
  return {
    ...doc,
    postContent: doc.postContent ? JSON.parse(doc.postContent) : null,
  };
}

Even something minimal like “allow parsing JSON strings into objects for specific fields” would already solve a lot of real-world cases.

Is there currently any hidden/undocumented way to do type transformation for specific fields in the Firestore extension?

If not, would you consider adding:

  • a mapping/transform config; or

  • a hook that lets us transform the record before indexing?

  • Thanks a lot for the awesome work on Typesense and the Firestore extension

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions