8000 AQL: GeoJSON returning as a string · Issue #7289 · arangodb/arangodb · GitHub
[go: up one dir, main page]

Skip to content

AQL: GeoJSON returning as a string #7289

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Philip-Wu opened this issue Nov 10, 2018 · 3 comments
Closed

AQL: GeoJSON returning as a string #7289

Philip-Wu opened this issue Nov 10, 2018 · 3 comments

Comments

@Philip-Wu
Copy link

My Environment

  • ArangoDB Version: 3.4.0 RC4
  • Storage Engine: RocksDB
  • Deployment Mode: Single Server
  • Deployment Strategy: ArangoDB Starter
  • Configuration:
  • Infrastructure: own
  • Operating System: Windows 7
  • Used Package:

Component, Query & Data

Affected feature: Geo queries and/or documentation

AQL query (if applicable):

Let geoPoint1 = {"coordinates":[-122.084,37.421997], "type":"Point" }
FOR geo IN Geo 
    Let geoPoint2 = geo.location
    Let geoDistance = GEO_DISTANCE(geoPoint1, geoPoint2)
    FILTER geoDistance != null && geoDistance  <= 30000 
    RETURN { "distance" : geoDistance, "location": geo.location}

AQL explain (if applicable):
Query String:
Let geoPoint1 = {"coordinates":[-122.084,37.421997], "type":"Point" }
FOR geo IN Geo
Let geoPoint2 = geo.location
Let geoDistance = GEO_DISTANCE(geoPoint1, geoPoint2)
FILTER geoDistance != null && geoDistance <= 30000
RETURN { "distance" : geoDistance, "location": geo.location}

Execution plan:
Id NodeType Est. Comment
1 SingletonNode 1 * ROOT
10 IndexNode 12 - FOR geo IN Geo /* geo index scan, projections: location /
5 CalculationNode 12 - LET geoDistance = GEO_DISTANCE({ "coordinates" : [ -122.084, 37.421997 ], "type" : "Point" }, geo.location) /
simple expression / / collections used: geo : Geo /
6 CalculationNode 12 - LET #4 = (geoDistance != null) /
simple expression /
7 FilterNode 12 - FILTER #4
8 CalculationNode 12 - LET #6 = { "distance" : geoDistance, "location" : geo.location } /
simple expression / / collections used: geo : Geo */
9 ReturnNode 12 - RETURN #6

Indexes used:
By Type Collection Unique Sparse Selectivity Fields Ranges
10 geo Geo false true n/a [ location ] (GEO_DISTANCE({ "coordinates" : [ -122.084, 37.421997 ], "type" : "Point" }, geo.location) <= 30000)

Functions used:
Name Deterministic Cacheable Uses V8
GEO_DISTANCE true true false

Optimization rules applied:
Id RuleName
1 move-calculations-up
2 move-filters-up
3 remove-unnecessary-calculations
4 move-calculations-up-2
5 move-filters-up-2
6 geo-index-optimizer
7 reduce-extraction-to-projection

Dataset:
No results are returned because geoDistance is null. The issue is because geoPoint2 is being returned purely as a string rather than a GeoJSON object.

Replication Factor & Number of Shards (Cluster only):
None

Steps to reproduce

Problem:

geoPoint2 is a string not a GeoJSON. To fix this query I had to wrap the string with JSON_PARSE as follows:

Let geoPoint2 = JSON_PARSE(geo.location)

Then it works as expected.

Expected result:

According to the documentation here: https://www.arangodb.com/arangodb-training-center/geojson-tutorial/

We should not have to convert the location string to GeoJSON.
Checking my Geo index I have:

127.0.0.1:8529@diggieDog> db.Geo.getIndexes();
[
  {
    "fields" : [
      "_key"
    ],
    "id" : "Geo/0",
    "selectivityEstimate" : 1,
    "sparse" : false,
    "type" : "primary",
    "unique" : true
  },
  {
    "bestIndexedLevel" : 17,
    "fields" : [
      "location"
    ],
    "geoJson" : true,
    "id" : "Geo/462717",
    "maxNumCoverCells" : 8,
    "sparse" : true,
    "type" : "geo",
    "unique" : false,
    "worstIndexedLevel" : 4
  }
]
@graetzer
Copy link
Contributor

Where does it say you can use a string ? Maybe the tutorial is unclear, but only JSON is supported not strings

@Philip-Wu
Copy link
Author

perhaps it was my mistake. I'm using the java driver to create my geoJSON which I saved as a string.
Any idea on how to save a geo JSON using the java driver?

@Philip-Wu
Copy link
Author

All good converted string to JSON object and added to BaseDocument. Thx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
0