question

Deekshith avatar image
Deekshith asked

Feature solutions

I have few questions on implementation of the following features, so wanted to confirm it before going ahead with my project in Playfab.

1 : Searching for all the players in the game by their username and it should be returning all the users whose username starts with the specified name instead of performing an exact match for username. Can this be done or any workaround for this feature? eg: Searching "williams" should return user list with usernames williams1, williamsmathew, williams21 and so on

2 : I will be adding some data related to player in player data(title) and another player should be able to get list of all users whose data matches or is in the given range specified. eg: Players has a player data key "kills". So another player should be able to get list of all users whose "kill" value is greater than "5"

3 : Consider there are 100k players in the game and out of them 10k users have "kills" value in player data(title) above "5" So what would be a better approach to get all these 10k player list? And also any solution to update the "kill" value to a new value or update/add a new value in player data(title) for all those 10k players?

Player DataapisFriends
10 |1200

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

1 Answer

·
Sarah Zhang avatar image
Sarah Zhang answered

>> 1. Can this be done or any workaround for this feature? eg: Searching "williams" should return user list with usernames williams1, williamsmathew, williams21 and so on

PlayFab does not support fuzzy search for players. There is a client API GetAccountInfo can retrieve the user's PlayFab account details via the player name or display name. The design of this API call is to return a single matching player, rather than a range of potential matches. In addition, customers cannot directly access PlayFab’s database too. Fuzzy search for players should be achieved using external service or be implemented by game developers selves.

>> 2.eg: Players has a player data key "kills". So another player should be able to get list of all users whose "kill" value is greater than "5"

It cannot be achieved by Player Data. But you can use Statistics and Player Segments features to put all players whose “kills” statistics value greater than 5 to one player segment. Then use Server API GetPlayersInSegment to page through all players in a given segment. This API creates a snapshot of all player profiles that match the segment definition at the time of its creation and lives through the Total Seconds to Live, refreshing its life span on each subsequent use of the Continuation Token. Profiles that change during the course of paging will not be reflected in the results. What should be noticed is this API is limited to being called 30 times in one minute. You will be returned an error if you exceed this threshold. All server API should be called on CloudScript or custom server, the client needs to interact with the server to use them. If you have lots of search needs, using custom servers combined with self-built data warehouses to manage such search features is a good choice. PlayFab back end service can play a supporting role at that time.

>> 3. Consider there are 100k players in the game and out of them 10k users have "kills" value in player data(title) above "5" So what would be a better approach to get all these 10k player list? And also any solution to update the "kill" value to a new value or update/add a new value in player data(title) for all those 10k players?

As the second answer said, Server API GetPlayersInSegment supports paging through all players in a given segment. If you follow the second answer to use Statistics(Leaderboards) to hold this “kill” value, the leaderboards can be reset directly, you can check this doc Using resettable statistics and leaderboards for more info. If you mean update all those 10k player’s statistics value to a meaningful value, you can combine CloudScript with Scheduled Tasks features to do bulk operations to players who in one Segment.

2 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.

Sarah Zhang avatar image Sarah Zhang commented ·

@Deekshith[Clarify the second point]If you only want to get a list of players with a score above a certain number, a better solution would be to just query the leaderboard itself. You can manually filter leaderboards lists based on your conditions.

0 Likes 0 ·
Deekshith avatar image Deekshith Sarah Zhang commented ·

Yes but there are 2 things :

- I wanted to store it in player data(title). For leaderboard I will have to store it in statistics which can be done

- If there are 100k users then querying for leaderboard and filtering won't help here, right?

0 Likes 0 ·

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.