question

brendan avatar image
brendan asked

Searching on non-unique title display names

Question from a developer:

Is there as solution to search for players by TitleDisplayName if we enabled “allow non unique display name”? The API GetAccountInfo will not return any valid response when we enable this option.

Account Management
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

brendan avatar image
brendan answered

You can use GetAccountInfo to look up players by PlayFab ID, Username, Email address, or Title Display Name, but for that last element, it's only if you leave the Title Display Name setting to requiring that they are unique (the default for all titles).

Non-unique Title Display Names cannot be searched on, as the lookup for that call requires uniqueness. In the case of non-unique names, there's no limit on the number of users that could match the provided name, technically.

11 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

kfboelter avatar image kfboelter commented ·

So what strategy should I use in case I am allowing a user to login via GameCenter, for instance, and taking his GameCenter name and setting that up as his display name, considering I have unique display name set to true?

Seems to my that out of this very simple and common thing to have (unique display name along with GameCenter login) I simply don't have a way to search and find users...

0 Likes 0 ·
brendan avatar image brendan kfboelter commented ·

You can look up the user's PlayFab ID from their Game Center ID via this API: https://api.playfab.com/documentation/client/method/GetPlayFabIDsFromGameCenterIDs. Game Center IDs are necessarily unique - if you have multiple routes that allow players to create accounts, such that you have to make the Title Display Name be non-unique, we can't really provide a lookup for it at the client level, as that could require a full table search across millions of users (and could result in returning the same number of partial matches).

0 Likes 0 ·
kfboelter avatar image kfboelter commented ·

Correction:

where I said " unique display name set to true", I meant "set to false". Seems you understood it, though :D

Your suggestion is pretty good, but problem with that is that if I don't know the user PlayFab ID in advance, I cannot search for it. Having several users with the same display name being returned from a search would help me, because I'd the get the rest of the user profile and display it, so then one of the users could be picked accordingly.

Apart from that solution you provided, any other thing I could do, considering my users logged in through gamecenter and do not have unique display names?

0 Likes 0 ·
brendan avatar image brendan kfboelter commented ·

No worries, I know what you meant. And in this case, you mean that if you don't have their GameCenter ID, you can't look it up, correct? Since Game Center IDs are unique, if you want to have that be the Title Display Name for your users I would use https://api.playfab.com/documentation/client/method/GetPlayFabIDsFromGameCenterIDs to check if there's an existing account for the local user, since you will have their GameCenter ID at that point (and that API call returns the PlayFab ID for the user that is associated with tat Game Center ID). If there is, depending on how you want to manage that, you could potentially unlink the Game Center account from that account and link it to the current player account.

If you want to support players entering Title Display Names and don't want to set the non-unique option, another thing you could do would be to use the option to append a randomly generated set of numbers onto the end of the Title Display Name (also in the title settings in the Game Manager), to help ensure uniqueness.

0 Likes 0 ·
jeffmyers avatar image jeffmyers commented ·

I am looking to implement a player search in my game, in which I'm also using non-unique display names.

I want to do a search for adding a friend, where the player searches by display name, gets all the profiles that have the same display name, looks through results, find the profile he was looking for (by avatar and user data), and adds him as a friend.

So seems there is literally no way to do that? This is very surprising.

0 Likes 0 ·
jeffmyers avatar image jeffmyers jeffmyers commented ·

Not sure what to do here. Non-unique display names are important for the design of my game, and so is player search.

0 Likes 0 ·
brendan avatar image brendan jeffmyers commented ·

The issue here is that if display names are non-unique, they're no longer index values. If something is an index value, it can be used for rapid lookup from a data table - which would rapidly grow to millions of entries, for a popular title. So indexed lookups are quick and inexpensive.

Searching on a non-indexed value means a far more expensive comparison operation on every entry, until the target is found. And, since you don't know that the first one you find is the correct one, you'd have to do a complete search of the data every time, and return all matching entries - which could be a massive number of hits. As you can imagine, this would be incredibly expensive to support relatively speaking. Since we want to be able to continue offering a free tier, and we want to keep our prices low for everyone, that's not something we can realistically afford to do.

0 Likes 0 ·
Show more comments
Anders Heie avatar image
Anders Heie answered
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.