Shortest path issue


#1

I have a query which returns two nodes:

{
  n1(func: uid(0x5fd3aa)) {
    uid
  }
  n2(func: uid(0x3f818)) {
    uid
  }
}

After expanding it looks like this:


JSON:

{
  "extensions": {
    "server_latency": {
      "parsing_ns": 14025,
      "processing_ns": 78008374,
      "encoding_ns": 815755
    },
    "txn": {
      "start_ts": 112
    }
  },
  "data": {
    "n1": [
      {
        "http://www.w3.org/2000/01/rdf-schema#label@en": "You Suck At Photoshop #19: Shadows and Light",
        "http://rdf.freebase.com/ns/type.object.name@en": "You Suck At Photoshop #19: Shadows and Light"
      }
    ],
    "n2": [
      {
        "http://rdf.freebase.com/ns/tv.tv_series_episode.season_number": "1",
        "http://www.w3.org/2000/01/rdf-schema#label@en": "You Have to Lose Sometimes",
        "http://rdf.freebase.com/ns/tv.tv_series_episode.air_date": 1384819200,
        "http://rdf.freebase.com/ns/common.topic.description@en": "Jersey holds auditions to find the next Hey Reb, as Chad takes a gig at a local country club. Michael channels the holiday spirit by decorating Rooty with Christmas lights.",
        "http://rdf.freebase.com/key/user.ovguide.tvdb_episode_id": "4731727",
        "http://rdf.freebase.com/ns/type.object.name@en": "You Have to Lose Sometimes",
        "http://rdf.freebase.com/ns/type.object.key": "/user/ovguide/tvdb_episode_id/4731727",
        "http://rdf.freebase.com/ns/tv.tv_series_episode.episode_number": "6"
      }
    ]
  }
}

As we can see, they are connected through several nodes with the same type of predicate http://rdf.freebase.com/ns/type.object.type

So there are two issues:

  1. Neither n1 nor n2 has that predicate in the predicates list
  2. Shortest path query shows they are not connected at all:
{
	p as shortest(from: 0x5fd3aa , to: 0x3f818) {
	<http://rdf.freebase.com/ns/type.object.type>
	}
	path(func: uid(p)) {
		uid
	}
}

Response:

{
  "extensions": {
    "server_latency": {
      "parsing_ns": 13251,
      "processing_ns": 4023324,
      "encoding_ns": 816343
    },
    "txn": {
      "start_ts": 111
    }
  },
  "data": {
    "path": []
  }
}

Is there a bug or am I doing it wrong?


(Daniel Mai) #2

http://rdf.freebase.com/ns/type.object.type doesn’t show up in the expand(_all_) query because a single expand() will get a single level of the edges.

At the very least, you must specify a nested level in the query to get data for the next depth.

{
  n1(func: uid(0x5fd3aa)) {
    expand(_all_) {
      uid
    }
  }
  n2(func: uid(0x3f818)) {
    expand(_all_) {
      uid
    }
  }
}

It sounds like n1 and n2 both have edges to nodes via http://rdf.freebase.com/ns/type.object.type, but n1 does not reach n2 via that edge. So,
n1 → common_node ←n2, not n1 → common_node → n2.


#3

So the only thing I can do to make it work is to add @reverse to schema?


(Daniel Mai) #4

Edges are uni-directional. So, you can use @reverse for that type edge to get the reverse direction.