Add metadata to Party with search capability

We are trying to search parties based on a metadata - region. This would basically allow us to show only those parties to the players that are in their server region.

Currently, Party doesn’t allow any metadata. And I assume if it would have allowed - it would be terrible at search since indexing would have been an issue. We have the following solutions and would love to understand the best way:

  1. Create a Collection “region_party_rel” with id as the region and store a dictionary of party IDs with value as True when they are created. As parties vanish, we set the value as false and later on remove the party from the list altogether in a Cron job.
  2. Create a separate collection for each region as they are limited in number and store party_id as ID and “true” as the value. As parties come online and go away, we remove the particular entries. This would allow us to fetch all parties of a region by getting all IDs from the region collection.
  1. Versions: Nakama {3.5}, {Windows, Mac, Linux binary or Docker}, {client library (SDK) and version}
  2. Server Framework Runtime language (If relevant) {Go, TS/JS, Lua}
{code or log snippet}

:tv: Media:

These are valid solutions, you will have to balance the tradeoffs according to your game. A third method is using temporary groups, you could filter the region using langTag and hold a reference to the party in the group metadata. Some considerations on each approach:

  1. Groups: may create a confusion with “real” permanent groups, and will need to manage setting up and tearing down groups reliably.
  2. One storage object per region: may create high contention on that object, and the value can get really large depending on your game.
  3. One storage object per party: will need indexing on every record, plus cleanup may be an issue (who deletes unnecessary objects, when, and can this be done reliably?)
1 Like

Thank you for your response. I think the idea of using temporary groups is best as we want to stick to functionality already provided by Nakama to not be limited in terms of scaling.

For the setting up and tearing down, we can use party_create and party_leave / party_close real-time hooks, where we can check if the closing party’s ID is the name of any group prepended with “prt_partyID” and remove that group as well.