Analysis plugin to access multiple fields from source document

I need to analyze a textual field based on other field in the source document. For example, let's say we have two separate documents:

// Document A
{
  "registry": "fi",
  "id": "FIN 1234"
}
// Document B
{
  "registry": "us",
  "id": "456 US 789"
}

I need to analyze & tokenize the "id"-field differently based on what's the value of the "registry"-field. How can this be achieved? I've tried to see the source-code of other Analysis plugins, but I cannot find a way to achieve this. Any tips?

Thank you!