Skip to content
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

AQL: Nearby Search #10

Open
cw00dw0rd opened this issue Feb 2, 2021 · 1 comment
Open

AQL: Nearby Search #10

cw00dw0rd opened this issue Feb 2, 2021 · 1 comment
Assignees
Labels
AQL AQL queries that are needed
Milestone

Comments

@cw00dw0rd
Copy link
Collaborator

Nearby search to show available rentals near a specified address.

@cw00dw0rd cw00dw0rd added the AQL AQL queries that are needed label Feb 2, 2021
@cw00dw0rd cw00dw0rd added this to the Initial Release milestone Feb 10, 2021
@Simran-B
Copy link
Collaborator

Simran-B commented Feb 11, 2021

Find rooms within a 100 meter radius of a coordinate:

LET co = GEO_POINT(13.45477, 52.51171)
FOR doc IN arangobnb
  SEARCH ANALYZER(GEO_DISTANCE(doc.location, co) < 100, "geo")
  LET distance = GEO_DISTANCE(doc.location, co)
  // Note: Web UI map view is triggered by presence of `geometry` attribute!
  RETURN MERGE(KEEP(doc, "name", "_key"), {distance, geometry: location})

Search listing locations within a rectangle:

LET rect = GEO_POLYGON([ [13.4, 52.4], [13.5, 52.4], [13.5, 52.45], [13.4, 52.45], [13.4, 52.4] ])

LET results = (
  FOR doc IN arangobnb
    SEARCH ANALYZER(GEO_CONTAINS(rect, doc.location), "geo")
    RETURN doc.location
)

// Hack to return the shape within we search as well
FOR r IN PUSH(results, rect)
  RETURN r

Find private rooms within a rectangle that feature a hot tub, heating and Wi-Fi and cost between [30, 50] dollars:

LET rect = GEO_POLYGON([ [13.2, 52.6], [13.5, 52.6], [13.5, 52.45], [13.2, 52.45], [13.2, 52.6] ])

LET results = (
  FOR doc IN arangobnb
    SEARCH ANALYZER(GEO_CONTAINS(rect, doc.location), "geo") AND
           doc.room_type == "Private room" /* identity analyzer */ AND
           ANALYZER(TOKENS("tub heating wifi", "text_en") ALL IN doc.amenities, "text_en") AND
           IN_RANGE(doc.price, 30, 50, true, true)
  RETURN doc.location
)

FOR r IN PUSH(results, rect)
  RETURN r

Pick a random neighborhood and find all listings in that polygon:

LET rect = FIRST(FOR n IN neighborhoods SORT RAND() LIMIT 1 RETURN n.geometry)

LET results = (
  FOR doc IN arangobnb
    SEARCH ANALYZER(GEO_CONTAINS(rect, doc.location), "geo")
    RETURN doc.location
)

// Hack to return the shape within we search as well
FOR r IN PUSH(results, rect)
  RETURN r

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

No branches or pull requests

2 participants