question

JJ avatar image
JJ asked

Filter Player by Username

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!

apisunity3dFriends
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

·
brendan avatar image
brendan answered

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.

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

JJ avatar image JJ commented ·

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

0 Likes 0 ·
brendan avatar image brendan ♦♦ JJ commented ·

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.

0 Likes 0 ·
JJ avatar image JJ brendan ♦♦ commented ·

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?

0 Likes 0 ·
Show more comments

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.

Error rendering WebPanel (widgets/consolidation-widget.ftl): org.hibernate.hql.internal.ast.QuerySyntaxException: AvailableConsolidation is not mapped [from AvailableConsolidation up where up.node = :node]