Hello! I am trying to create a feature whereby one user can search for other players through a search field.
For instance, there could be 5 players - > "Tom", "Terry", "Terrence", "Bob" and "Adam"
Suppose "Bob" enter in the search field the character "T", I should be able to receive a list of "Tom", "Terry" and "Terrence", and when he enters the 2nd character e, only "Terry" and "Terrence" should remain.
I saw a similar question posted 5 years ago
(https://community.playfab.com/questions/97/205460918-search-other-player.html) and understand that the recommendation is to get all the player once, then search on the client-side.
Since its been quite a long time, I would like to ask the PlayFab admins if this is still the recommended approach?
Cheers!
Answer by Brendan · Jan 11 at 09:39 PM
Since we do not support wildcard (or partial) search on usernames via the API calls (since that would be inefficient and expensive), you would need to store the player usernames in an external database and query that. You could use the events (via a Webhook or the Event Export functionality) to populate that data. But please bear in mind that you would need to account for any privacy requirements for that data.
Hi Brendan, I think that would be an overkill for me since its only a minor project for me. I have seen the usage of getting player segment, and I think it fits my purpose perfectly. I only have i.e. 5 users for testing now, I merely want to grab all user and create a filter function from there.
May I clarify how I can get a List of All Player? So far I have only found
`PlayFabClientAPI.GetPlayerSegments`, but I cant seem to get it to work. I would like to use the solution of getting all players, then doing the filtering at client side.
Thank you very much for reading this
There isn't a valid path for this using the built-in functionality.
GetPlayersInSegment will return the specific users in a segment. If it's a non-trivial number of users, you would use the Continuation Token to get the next set iteratively, until you're done. However:
A) GetPlayersInSegment should not be triggered by a client call (to Cloud Script or a server) because it is very computationally expensive. In fact, because it is, the call rate limit on that endpoint is for the title, not for individual clients or servers. So if you tried to do this, you'd run into that limit even with a very small number of players.
B) This would be very expensive for you, since it would hit the Profile Read meter (Profile Reads Meter API Description - PlayFab | Microsoft Docs). It would "tick" that meter based on the total volume of data returned, per call - specifically max(1, bytes returned divided by 1,000) each call.
Hi Brendan. Thanks very much for the prompt response.
It seems like my approach isn't very suitable after hearing your feedback. May I clarify if your recommendation is for me to store the player data in both playfab and a external db, so if I want to i.e. filter by username, I will write query to filter FROM my external db - since PlayFab doesn't support this feature/is not effective for this purpose?
What happened to the OneSignal addon? (having iOS push errors with PlayFab) 1 Answer
OffTopic help. Regarding Facebook Friends profile pictures. 1 Answer
Google Play Games: Silent Login 1 Answer
OAuth consent screen and Playfab: Can't verify because I don't own playfab.com domain 2 Answers
Add Friend using friend request with accept/decline option 1 Answer