Skip to content

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 2 years ago179 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 2 years ago

EXPERT

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