Geo Queries in v1+

Just started testing Geo Queries today with our data after migrating to v1.0.5 for Dgraph, and then I went to the master build. It would seem that neither of them have functional geo queries at all?

We relied heavily on get “near” queries and they seem to not work at all. The index is there, and the type is Geo. The geojson is stored correctly, and it worked back in 0.8.3. We need this to continue using, as we are about to be live with this version.

We are running the latest docker image from Dgraph, but I also tested with the 1.0.5 docker image. Same result.

We have 3 servers, replication 3x, one dgraph zero.

Example:

This Entity location is in our graph:

"ENTITY_location_general": {
          "type": "Point",
          "coordinates": [
            -86.158068,
            39.768403
          ]
        },

This query still returns nothing:

{
	start(func: near(ENTITY_location_general, [-86.158068, 39.768403], 4000))	{
		ENTITY_id
    ENTITY_name
    ENTITY_location_general
  }
}

In matter of testing or “debug” try this out

{
  tourist(func: has(ENTITY_location_general) ) {
    uid
    expand(_all_)
  }
}

If nothing returns, something wrong in your mutation model.
Could you inform how your mutation is?

i have expand all turned off, but ill try

{
  tourist(func: has(ENTITY_location_general), first: 10 ) {
    uid
    ENTITY_location_general
  }
}

produced

{
  "data": {
    "tourist": [
      {
        "uid": "0x19",
        "ENTITY_location_general": {
          "type": "Point",
          "coordinates": [
            -86.158068,
            39.768403
          ]
        }
      },
      {
        "uid": "0x1a",
        "ENTITY_location_general": {
          "type": "Point",
          "coordinates": [
            -86.158068,
            39.768403
          ]
        }
      },
      {
        "uid": "0x24",
        "ENTITY_location_general": {
          "type": "Point",
          "coordinates": [
            -122.143019,
            37.441883
          ]
        }
      },
      {
        "uid": "0x2a",
        "ENTITY_location_general": {
          "type": "Point",
          "coordinates": [
            -122.419415,
            37.774929
          ]
        }
      },
      {
        "uid": "0x2b",
        "ENTITY_location_general": {
          "type": "Point",
          "coordinates": [
            -122.083851,
            37.386052
          ]
        }
      },
      {
        "uid": "0x16e",
        "ENTITY_location_general": {
          "type": "Point",
          "coordinates": [
            -87.918392,
            41.74892
          ]
        }
      },
      {
        "uid": "0x16f",
        "ENTITY_location_general": {
          "type": "Point",
          "coordinates": [
            -112.074037,
            33.448377
          ]
        }
      },
      {
        "uid": "0x173",
        "ENTITY_location_general": {
          "type": "Point",
          "coordinates": [
            -122.271079,
            37.558546
          ]
        }
      },
      {
        "uid": "0x174",
        "ENTITY_location_general": {
          "type": "Point",
          "coordinates": [
            -90.671797,
            40.459208
          ]
        }
      },
      {
        "uid": "0x176",
        "ENTITY_location_general": {
          "type": "Point",
          "coordinates": [
            -94.528333,
            45.125833
          ]
        }
      }
    ]
  },
  "extensions": {
    "server_latency": {
      "parsing_ns": 18891,
      "processing_ns": 30688514,
      "encoding_ns": 710010
    },
    "txn": {
      "start_ts": 1749768,
      "lin_read": {
        "ids": {
          "1": 599196
        }
      }
    }
  }
}

I use the golang client’s “SetJson” with json like so:

[{"uid":"0x45f0a","ENTITY_location_general":"{\"type\":\"Point\",\"coordinates\":[-71.348948,42.460372]}","ENTITY_locationProcessed":true,"ENTITY_PROFILE_addresses":"ClASAlVTGgJNQSIHQ29uY29yZCoRMzAwIEJha2VyIEF2ZW51ZSBCBTAxNzQyUiMzMDAgQmFrZXIgQXZlbnVlICBDb25jb3JkLCBNQSAwMTc0Mg=="}]

Ok, seems okay your data. Well, I can’t replicate according to its context and then report a problem right now. But still I try this week.

I see that are two points close. This should return someting. Can you try a bigger distance? just for the record.

Yes i did like 9999999 and still nothing. I also tried a within, etc, and nothing worked with Geo for me.

Are you using this context for study or are you already using it in production?
Could you export this data and try in a version of Dgraph in Docker?

And please show this related predicates as they are in your schema.

Yeah, I am ready to go live with it very soon. We were live with 0.8.3, just updating, and this should roll out next week sometime. Also, it is in the docker image, its the “latest” image right now. We run it through core OS on GCE machines. The entity in general looks like so:

ENTITY_id: string  @index(hash) .
ENTITY_hasAccount: uid . 
ENTITY_hasRelationshipWith: uid @reverse .
ENTITY_PROFILE_names: string @index(hash) .
ENTITY_PROFILE_emails: string @index(hash) .
ENTITY_PROFILE_addresses: string @index(hash) .
ENTITY_PROFILE_urls: string @index(hash) .
ENTITY_PROFILE_images: string @index(hash) .
ENTITY_PROFILE_jobs: string @index(hash) .
ENTITY_PROFILE_dob: string @index(hash) .
ENTITY_PROFILE_educations: string @index(hash) .
ENTITY_PROFILE_ethnicity: string @index(hash) .
ENTITY_PROFILE_gender: string @index(hash) .
ENTITY_PROFILE_overview: string @index(hash) .
ENTITY_PROFILE_username: string @index(hash) .
ENTITY_PROFILE_phones: string @index(hash) .
ENTITY_PROFILE_recommendations: string @index(hash) .
ENTITY_PROFILE_tags: string @index(hash) .
ENTITY_PROFILE_categories: string @index(hash) .
ENTITY_PROFILE_metrics: string @index(hash) .
ENTITY_PROFILE_notes: string @index(hash) .
ENTITY_PROFILE_birthdaySearchValue: float @index(float) . 
ENTITY_type: int @index(int) .
ENTITY_resolvedType: int @index(int) .
ENTITY_name: string @index(hash) .
ENTITY_hasTag: uid @reverse .
ENTITY_resolvedName: string @index(hash, trigram) .
ENTITY_location_general: geo @index(geo) .
ENTITY_locationProcessed: bool @index(bool) .
ENTITY_hasEntityFeedback: uid @reverse . 
ENTITY_hasMaster: uid @reverse . 
ENTITY_hasSuggestion: uid @reverse . 
ENTITY_imageFaceCount: int @index(int) .
ENTITY_processedLevel: int @index(int) .
ENTITY_traversalEdge: uid @reverse .
ENTITY_lastEnrichedOn: int @index(int) .

This is odd, should work. I’ll come back to you when able to reproduce it, you can delete the schema if it’s a private info. I already checked it all ok. Also you query and you JSON are ok.

1 Like