GEO_DISTANCE search in view returns nothing, even though ANALYZER returns true

41 Views Asked by At

I'm trying to perform a geospatial search in ArangoDB and even though the analyzer returns true, the search results are empty.

The query attempts to find all users who are within range (distanceMeters) of this user:

FOR user IN users
  FILTER user._key == 'c8a8d416-a0c2-4cc4-b583-ad0a8bfb3389'
  LET userLocation = GEO_POINT(user.location[0], user.location[1])
  LET distanceMeters = 100 * 1609
  
  FOR targetUser IN UserSearch
    SEARCH ANALYZER(GEO_DISTANCE(userLocation, targetUser.location) < distanceMeters, "geoPair")
    LET analysis = ANALYZER(GEO_DISTANCE(userLocation, targetUser.location) <= distanceMeters, "geoPair")
    LET distance = ROUND(GEO_DISTANCE(targetUser.location, user.location))
    
    SORT distance
    LIMIT 10
    
    RETURN {
        analysis,
        distance,
        userLocation: user.location,
        targetLocation: targetUser.location,
    }

This returns an empty array

[]

If I comment out the SEARCH line, it returns results with the analysis attribute set to true:

[
  { "analysis":true, "distance":0, "userLocation":[37.80435,-122.271164], "targetLocation":[44.05207,-123.086754] },
  { "analysis":true, "distance":0, "userLocation":[37.80435,-122.271164], "targetLocation":[34.151783,-118.45889] },
  { "analysis":true, "distance":0, "userLocation":[37.80435,-122.271164], "targetLocation":[37.33874,-121.885254] }
]

Additional Details

ArangoDB version: 3.11.4

The UserSearch view definition:

{
  "writebufferSizeMax": 33554432,
  "id": "9348168",
  "storedValues": [],
  "name": "UserSearch",
  "type": "arangosearch",
  "consolidationPolicy": {
    "type": "tier",
    "segmentsBytesFloor": 2097152,
    "segmentsBytesMax": 5368709120,
    "segmentsMax": 10,
    "segmentsMin": 1,
    "minScore": 0
  },
  "writebufferActive": 0,
  "links": {
    "users": {
      "analyzers": [
        "identity"
      ],
      "fields": {
        "location": {
          "analyzers": [
            "geoPair"
          ]
        }
      },
      "includeAllFields": true,
      "storeValues": "none",
      "trackListPositions": false
    }
  },
  "commitIntervalMsec": 1000,
  "consolidationIntervalMsec": 1000,
  "globallyUniqueId": "h6E0356583726/9348168",
  "cleanupIntervalStep": 2,
  "primarySort": [],
  "primarySortCompression": "lz4",
  "writebufferIdle": 64
}

An example of a user document:

{
  "birthday": 348278400000,
  "gender": "man",
  "name": "Jeremy",
  "lastActive": 1698800214523,
  "location": [
    37.80435,
    -122.271164
  ]
}
0

There are 0 best solutions below