Orderasc and index dependency


(Thorsten Ulbrich) #1

In the following example, the result set changes depending on whether the predicate is indexed or not:

<isAssetFolder>: string @index(exact) .

Query:

{
  getAssets(func: eq(xid, "ee6a27c5-0232-4ff3-aa5d-1ddd75adc14e")) {
    uid
    assets: parent_of  (orderasc: isAssetFolder, orderasc: name)
    {        
      name        
      isAsset        
      isAssetFolder    
    } 
  } 
}

Result with index on isAssetFolder:

"data": {
    "getAssets": [
      {
        "uid": "0x492e1b"
      }
    ]
  }

Result after dropping the index on isAssetFolder:

"data": {
    "getAssets": [
      {
        "uid": "0x492e1b",
        "assets": [
          {
            "name": "A+A15_JV5067jpg",
            "isAsset": "",
            "uid": "0x43fe08"
          },
          {
            "name": "A+A15_JV4981jpg",
            "isAsset": "",
            "uid": "0x4a6653"
          },
          {
            "name": "A+A15_JV5491jpg",
            "isAsset": "",
            "uid": "0x4f214b"
          }
        ]
      }
    ]
  }

The latter result was the expected. But why does an indexed field lead to the suppression of the other results when sorting?


(Michel Conrado) #2

Hi Thorsten Ulbrich,

Check this issue https://github.com/dgraph-io/dgraph/issues/2686
All field must have data and be indexed.

It seems that none of the nodes has “isAssetFolder”.


(Thorsten Ulbrich) #3

If the predicate from orderasc (isAssetFolder) is not indexed, all results are returned, but if isAssetFolder is indexed, only results with isAssetFolder as predicate are returned.

Is it correct to conclude that all nodes in a result set must have the indexed predicate of the order clause?