Comments (5)
Group and count amenities (this is pretty fast, ~500ms):
RETURN MERGE(
FOR doc IN arangobnb
FOR a IN doc.amenities
COLLECT amenity = a WITH COUNT INTO count
RETURN { [amenity]: count }
)
It's apparently free-text, not sure how suitable it is for auto-complete. We could still display a list of everything that has a count of over 20 or so and provide auto-complete for that. To implement this server side, we would need another View and collection (update periodically with a Foxx job?).
from arangobnb.
Why the merge? This seems to provide the expected results and is ~150ms:
FOR doc in arangobnb
FOR amenity in doc.amenities
COLLECT item = amenity with COUNT into c
SORT c DESC
LIMIT 20
RETURN item
This could have a LIMIT and then we could have a separate query for text search. WDYT?
from arangobnb.
MERGE() is merely used to create a mapping, amenity to count, instead of returning an object per amenity with two keys. It's just for displaying the result in a more compact way here.
150ms is still not particularly fast for production purposes if we consider that this is Berlin only and that query caching would potentially not help in a real world application where the data changes quite often. It's fine for demonstration purposes, but this seems like an important point if we want to show scalability.
from arangobnb.
We can get this down to around 1ms if we combine it with the mapResults
query but that means we would need to adjust the markers being displayed to keep them consistent with the filters, this shouldn't be a problem but will likely result in fewer markers on the map.
I would need to test the performance of loading the increased number of markers with each map drag, instead of only adding new ones.
Increasing the LIMIT on the listings returned does not add much to the query time, it would just be a matter of response time.
LET listings = (
FOR listing IN arangobnb
SEARCH ANALYZER(GEO_CONTAINS(GEO_POLYGON(@poly), listing.location), "geo")
LIMIT 20
RETURN listing
)
Let filters = (
FOR doc in listings
FOR amenity in doc.amenities
COLLECT item = amenity with COUNT into c
SORT c DESC
LIMIT 20
RETURN item
)
RETURN {listings,filters}
from arangobnb.
Returning the filters with the results, increasing the number of listings returned, and displaying more markers on-screen has a negligible performance impact.
Here is what I have done so far:
- Added a sort to the listings based on ratings, this keeps results relevant but to keep it performant required adding primarySort. I decided on the number of reviews and the review rating, open to suggestions.
- Updated the results query to also, optionally, consider the price range, amenities, and room type (similar to here)
- Added some basic Vue elements to interact with this (see PR)
This results in a fast query that is able to return the filters found in the results as well as filter the results based on user-selected criteria. This also takes advantage of more ArangoSearch optimization with primarySort
.
However, the new issue that has arisen is the need to refactor the map markers to handle the higher volume and update when filters are selected.
Here is the query with some preset values.
LET listings = (
FOR listing IN arangobnb
SEARCH ANALYZER(GEO_CONTAINS(GEO_POLYGON(@poly), listing.location), "geo")
AND
ANALYZER(["Private room", "Entire home/apt"] ANY IN listing.room_type, "identity")
AND
ANALYZER(["Wifi", "Heating"] ALL IN listing.amenities, "identity")
AND
IN_RANGE(listing.price, 30, 50, true, true)
SORT listing.number_of_reviews DESC, listing.review_scores_rating DESC
LIMIT 100
RETURN listing
)
Let filters = (
FOR doc in listings
FOR amenity in doc.amenities
COLLECT item = amenity with COUNT into c
SORT c DESC
LIMIT 100
RETURN item
)
RETURN {listings, filters}
from arangobnb.
Related Issues (20)
- Frontend: Date functionality HOT 1
- Frontend: Guests Functionality
- Frontend: Theme & Background Hero Image HOT 3
- Backend: View Creation HOT 3
- AQL: Nearby Search HOT 1
- AQL: Natural Language Description Search HOT 1
- Frontend: Search Bar HOT 1
- Frontend: Filter Component HOT 1
- Frontend: Results Component HOT 1
- AQL: Dataset Modeling HOT 7
- Backend: KOA setup
- Backend: Foxx Microservice
- Project Structure HOT 3
- Backend: Reviews Language Data Modeling HOT 1
- Frontend: Map View HOT 2
- Frontend: AQL Query Display
- Documentation: Clarify which version of ArangoDB to use HOT 6
- Analyzer geo not found after importing dump HOT 3
- GeoCode Search is broken
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arangobnb.