New user issues: documentation, expand, ratel

New user, as in barely 24hrs.

I’m dutifully following along the tour for 1.2.1, running the examples against my local install. Mostly all good!

1: Movies Schema | Moredata | Dgraph Tour
This page mentions starting off with a query to learn the schema, and then proceeds to extend the query. The problem is the initial query is missing. The run tab contains the alterations to create Person, Movie, etc.

Let’s have a look from the perspective of directors. Kathryn Bigelow directed the early 90’s classic Point Break. We’ll begin with her and learn about the schema.

Checking the Type Schema tells us that directors as a “Person Type” have a name and are connected to the movies they directed via director.film.

Extend the query a level deeper by also including...

2: To try and better grok the relationships, I keep looking at the Schema tab in Ratel and modify my queries accordingly. I got frustrated as I was missing something, so I tried to use expand(_all_), which had been mentioned in the guide. It doesn’t provide any extra data, or I’m using it incorrectly. e.g.

{
  marty(func: allofterms(name@en, "Martin Scorsese"))   {
   expand(_all_)      
  }
}

provides me

  "data": {
    "marty": [
      {
        "name@en": "Martin Scorsese"
      }
    ]
  }

I even tried several layers of expand(_all_), but nothing. A search showed me a post by Francesc that included the usage of @recurse(depth:N) which now begins to show me name, release date, genre names.

  "data": {
    "marty": [
      {
        "name@en": "Martin Scorsese",
        "director.film": [
          {
            "name@en": "Kundun",
            "name@it": "Kundun",
            "name@de": "Kundun",
            "initial_release_date": "1997-12-25T00:00:00Z",
            "genre": [
              {
                "name@en": "War film"
              } ...

Can someone please provide clarity on what I’m doing / not doing / should be doing?

3: I explored the Geo tab in Ratel, and it said I needed to have a location field. So, I naively added one as a int to represent a USA zip code. After adding data and going to the Geo tab, Ratel went blank screen. I couldn’t switch back to any tab; even tried restarting servers. I checked the browser console and saw errors about not having “lat” and such, which made sense. I was able to recover using Ratel by clearing the cookies. :slight_smile:

I apologize for 3 different items in one post, but I didn’t want to appear to be spamming by starting my journey posting several at once.

I thank you in advance for any guidance you can provide!

docker image info:

REPOSITORY TAG IMAGE ID CREATED SIZE
dgraph/dgraph latest c315184cd134 2 weeks ago 153MB

Dgraph version : v20.03.0
Dgraph SHA-256 : 07e63901be984bd20a3505a2ee5840bb8fc4f72cc7749c485f9f77db15b9b75a
Commit SHA-1 : 147c8df9
Commit timestamp : 2020-03-30 17:28:31 -0700
Branch : HEAD
Go version : go1.14.1

Yes, This part was changed because it contained a function that has been discontinued. At the moment there is an engineer reformulating this part.

A single expand all will expand only predicates of the first level. You have to use

expand(_all_) {
   expand(_all_)      
  }

to be able to expand outgoing edges.

You can go to Dgraph Ratel Dashboard
and run this query:

{
  tourist(func: near(loc, [-122.469829, 37.771935], 1000) ) {
    name : name
    location: loc
  }
}

After that, take a look at the JSON structure. So you gonna see the sort of “geojson” in location: loc. You can get an idea of how it works. Also take a look at Query Language - Query language

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.