Query multiple game modes TS

Hi there, I have a technical question about the query syntax as described in the documentation
I’m currently making an authoritative multiplayer game with multiple game modes.
The players have the option to play a specific game mode, or queue for a random mode.

Now in the documentation it states that I can provide an array of values so the matchList function can return multiple matches with different label values,

Queries also inspect individual elements inside an array for a match. For example, an indexed value: {"field": [5, 10, 15]} will be returned as a match for any query including a term field:5 , field:10 , or field:15 .

When I ask for a match I check if there are any matches and else I’ll create one with the correct game-mode on the label.

 let request = parse(payload);
    let matches = getMatches(request)
    let matchIds: string[] = [];
    if (matches.length > 0) {
        // There are one or more ongoing matches the user could join.
        matchIds = matches.map(m => m.matchId);
    } else {
        // No available matches found, create a new one.
        matchIds.push(createMatch(request))
    }

    let res: RpcFindMatchResponse = { matchIds };
    return JSON.stringify(res);

But Now I’m encountering a problem that when I notate the query as an array of [0,1] it won’t return any of the existing matches that have game mode 0 or 1. When I write the query as
"+label.open:1 +label.gameMode:0" or "+label.open:1 +label.gameMode:0" it does find them so now I’m left wondering if this functionality of the query syntax is broken because I don’t receive any errors because then I would catch them.

function getMatches(request): nkruntime.Match[]{
    try {
        // const query = request.query; 
        const query = "+label.open:1 +label.gameMode:[0,1]"
        log.debug("the query %v",query);
        return nk.matchList(10, true,null, null, 1, query);
    } catch (error) {
        log.error('Error listing matches: %v', error);
        throw error;
    }
}
function createMatch(request){
    try {
        //TODO, create match based on gametype
        log.info("creating match")
        let gameMode = getGameMode(request.gameModes)
        log.info(gameMode.toString())

        return nk.matchCreate(gameMode, {fast: request.fast, query: request.query});
    } catch (error) {
        log.error('Error creating match: %v', error);
        throw error;
    }
}

I know my match has a int declared in the label because I can see them in the nakama console

I couldn’t find an example on the documentation or forum on how to use an search array.
Does any-one of you know how I could make use of the correct syntax?

@Aaron If I understand correctly, you’re looking to query matches where gameMode is either 0 or 1? Can you share the query you’ve actually tried that didn’t seem to work?

If my assumption above is right, then the documentation section you’ve quoted isn’t relevant to you. That talks about queries matching indexed arrays, so let’s say you have {"gameMode":[1,2,3]} as your match label then query +label.gameMode:2 would find that match.

Hi @zyro, yes! in this case I’m looking for matches that have gameMode 0 or 1 (originally they were strings but I’ve changed it to numbers to simplify/debug the query)
so the query I was using is:

  const query = "+label.open:1 +label.gameMode:[0,1]"
  return nk.matchList(10, true,null, null, 1, query);

with my label being: {"open":1,"gameMode":0,"fast":0}
so when the first player connects, there are no matches so it creates one with the above label.
then when a second player connects, the the search function would return an empty array.

I follow now, there are a few options you could try. I think the query label.gameMode:0 label.gameMode:1 should work. Note the lack of +!

If that doesn’t quite give you what you want (perhaps includes unwanted results) then try inverting the query. So if your possible game mode values are 0,1,2,3 and you want 0,1 then use the query -label.gameMode:2 -label.gameMode:3 effectively saying “where the game mode is not 2 or 3” leaving only the game modes you actually want.