Dynamic query-time synonyms

I'm doing synonyms but for different reasons (many users in 1 index each with different synonyms) I need to handle synonyms only at query time. What is the best way to do this currently in es ?

Currently I'm thinking a process like:

  1. analyze query and get tokens from es without searching
  2. check tokens with other db for synonyms
  3. rebuild query to es with synonyms for the current tokens included

Does this make sense ? Am I missing something? How would I do step 3 ?

Thanks!

You might want to checkout

To quote from the page linking to that: Expand or contract | Elasticsearch: The Definitive Guide [2.x] | Elastic

Alternatively, if we don’t use synonyms at index time, then at search time, we would need to convert a query for English into a query for english OR british.

As a side question: What's your reason for having multiple users in one index?

Hope this helps,
Isabel

@mainec
Because the number of users is big (at least thousands, hopefully low million) and I can't have that many indexes/shards because of the overhead.

I'll check it out and reply again if I still have questions.