Git Product home page Git Product logo

Comments (1)

Simran-B avatar Simran-B commented on June 28, 2024

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

from arangobnb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.