Sign In Register

How can we help you today?

Start a new topic

Data Explorer query returns nothing

I created a data type PLAYER with CITY field, after that I added two players with Insert tab in Data Explorer. I can find both players by Id, but any Query returns nothing. I thied with no rules, rules with some CITY fields (they definilety exists). That i am doing wrong?

Hi Vladimir,

If you've got the city field created then it is indexed and will be queryable. What query are you using here exactly ?




Thanks for the quick response!

I attached two screenshots with query example in Data Explorer.

I also tried get query with followed cloud code:

var API = Spark.getGameDataService();

// Tried two variants

1) var condition = API.S("CITY").eq("New York")

2) var condition = API.S("CITY").ne("some random string")

var query = API.queryItems("PLAYER", condition);


    //Output error script

    Spark.setScriptError("ERROR", query.error());

    //Stop execution of script


} else{

    //Create empty object

    var entryOBJ = {};

    //While there are still entries in the cursor retrieved from query


        //Get the entry

        entry = query.cursor().next();

        //Populate object with the entries. key = entry ID

        entryOBJ[entry.getId()] = entry.getData();


    //Return entries via scriptData

    Spark.setScriptData("data", entryOBJ);


My data field in response always empty.

(74.5 KB)
(126 KB)

Hi Vladimir,

I think the data type path is not configured correctly here. Can you change the path for "CITY" to "CITY" and try the query again please ?



Yea, it works! Thank you very much.

I used this Adding a Game Data Index tutorial and therein Short Code and Path are different. This confused me. Perhaps a remark is needed that they should be the same.



1 person likes this

I had the same problem and changing the path to be identical to the shortcode solved the problem. but what exactly is the use of a path element?

I saw in some parts of the tutorial (the index advisor part) that path can be different. so how is that possible and under what conditions?

Hi Vladimir and Vahid,

The path specified when defining your index indicates where in your data the field you are indexing is located. The shortCode on the other hand is the text/name you would specify when querying this field. For example, say you had a document containing some character equipment that looked like this:










To add an index to the sword field you would specify the path as 'weapon.sword', but the shortCode can be named whatever you want. Let's say we give the index a shortCode of "swd" - this is now the term you would use in queries to check the 'weapon.sword' field:

var gds = Spark.getGameDataService();

var query = gds.S("swd").eq("straightsword");

var result = gds.queryItems("playerEquipment", query);

This makes it easier to query embedded fields as there's no need to re-specify the entire path to the field you want each time you're querying.

I hope this helps clear things up.



Login to post a comment