question

Jim Perry avatar image
Jim Perry asked

Filtering UGC Search

I have a catalog that's holding levels created by users. Other users can select levels that they haven't created to play. I need a way to filter out levels that a user has already completed and that they haven't created. It doesn't seem like the operators and fields that are available allow this. Ideally I would do something like "!(ID Contains {x,y,x})". Is something like this possible?

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

·
Gosen Gao avatar image
Gosen Gao answered

Such functionality may not be possible through UGC search. “!(ID Contains {x,y,z})“ in UGC search will be “id ne ‘x’ and id ne ‘y’ and id ne ‘z’”, refer to UGC SearchItems. But since we are limiting the complexity of search filter queries that can run in any given request, this statement can use up to 3 “and”s. If you want to exclude more than 5 ids, you can't do it with search.

As a workaround, you may need to save the levels the player has played in Player Data, and every time you want to get a new level, you can get some levels from the UGC and compare with this record to remove the ones the player has played.

According to your description "levels that a user has already completed and that they haven't created", it seems like that you know all the levels. If that is the case, you should be able to get the levels the player hasn’t played. Then you can search some of these un-played levels from UGC.

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.

Jim Perry avatar image Jim Perry commented ·

Thanks for responding.

I don't know how many levels there will be, since they're player created. Eventually (if the game does well) there could be thousands. They're only playable by a player once and the time it takes to complete it is stored in player data. That's where I get the levels a player has already played. After a while, this could be dozens, hundreds, etc. I need an efficient way to grab 20 levels at a time the player hasn't played, out of possibly thousands they're already completed and thousands, or more, they haven't.

It doesn't seem like the API at this point is robust enough to handle such a query. :(

If the data was stored in a database, I could do a join of the top 20 easily. I don't know if this is possible with PlayFab however.

0 Likes 0 ·
Gosen Gao avatar image Gosen Gao Jim Perry commented ·

If your game needs to specify hundreds of data to exclude when querying, then the UGC search API cannot handle such a query.

You could set "OrderBy" to "CreationDate desc" to get the latest items via SearchItems.

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.