By using AWS re:Post, you agree to the AWS re:Post Terms of Use

Game Session Property Filter for SearchGameSessionsCommand

0

Hello,

I am trying to search for GameLift game sessions using the SearchGameSessionsCommand. I want to filter the results using the "FilterExpression" field, and filter the results by the properties set in gameSessionProperties. Since gameSessionProperties is an array of key/pair values, can I filter by multiple game session property values as follows:

  const client = new GameLiftClient(config)

  let filter = `gameSessionProperties.mode = '${req.body.mode}' AND gameSessionProperties.type = '${req.body.type}' AND gameSessionProperties.tournamentId = ''`;

  const input = {
    Location: req.body.region,
    FilterExpression: filter
  };
  const searchCommand = new SearchGameSessionsCommand(input);
  const searchResponse = await client.send(searchCommand);
asked a month ago26 views
1 Answer
1
Accepted Answer

Yes, you can filter on multiple game session properties. See https://docs.aws.amazon.com/gamelift/latest/apireference/API_SearchGameSessions.html and specifically the example "Search game sessions by custom game properties" near the bottom of the page.

Here is the sample request from the example:

{
    "FleetId": "fleet-9999ffff-88ee-77dd-66cc-5555bbbb44aa",
    "Location": "us-west-2",
    "FilterExpression": "gameSessionProperties.gameMode = 'Ffa' AND gameSessionProperties.gameMap = 'Suzuka' OR gameSessionProperties.gameMap = 'Silverstone'",
    "SortExpression": "gameSessionProperties.difficulty ASC"
    "Limit": 2
}
    
CLI syntax:
    aws gamelift search-game-sessions --fleet-id "9999ffff-88ee-77dd-66cc-5555bbbb44aa" --filter-expression "gameSessionProperties.gameMode = 'Ffa' AND gameSessionProperties.gameMap = 'Suzuka' OR gameSessionProperties.gameMap = 'Silverstone'" --sort-expression "gameSessionProperties.difficulty DESC"              
AWS
answered a month ago
profile picture
EXPERT
reviewed 25 days ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions