Databases, obviously, are made to store data. But just as importantly, they need to fetch that data in response to queries, and they should do it fast.
Here we’ll tell you about all the tools RavenDB gives you to map your documents with indexes, analyze text and spatial data, project your data into new shapes, and more. We’ll also explain how RavenDB automatically learns from your users’ queries so it can respond to them more quickly. Just a few of our features include:
- Dynamic indexing
- Full-text search
- Facet queries
- Geospatial queries
- Server-side projections
- Flexible sorting
- Fetching related data
- Complex aggregations and map-reduce
As information grows exponentially, and users demand more and more, querying use-cases are more complex than ever. Most databases can’t keep up, but we at Hibernating Rhinos are ahead of the curve with our advanced query engine. Our unique approach is flexible, scalable, performant, and will help your business continue to thrive in a data driven world.
Google and Amazon have discovered that even tiny delays shorter than a second can significantly reduce user retention. This is why RavenDB indexes update in the background rather than locking your data: it’s better to serve a query with data that’s a few milliseconds out of date (or “stale“) than to keep your users waiting. With each query you’re informed of the index’s exact status so you can make the best decision on how to use it.
RavenDB learns from past queries to expand and optimize its index repertoire. When RavenDB receives queries that can’t be satisfied by any existing index, it doesn’t just make the same costly full table scan over and over. It automatically creates a new dynamic index which will satisfy all similar queries in the future, resulting in an immediate boost in speed with no work on your part.
Using your custom, or “static” indexes, your server will efficiently answer almost any query your users can imagine. Indexes can cover multiple fields and collections, perform complex data manipulation, and are highly configurable to suit your needs. Learn more about how indexes work in RavenDB here.
Your Querying Toolkit
RavenDB queries have many capabilities that our competitors lack, like:
RavenDB comes equipped with several Lucene analyzers that slice text into the searchable tokens that can be queried. Each analyzer takes a different approach to reflect the subtleties of language, taking into account: numerical and lexicographic order, case, word stemming, punctuation, symbols, or even identifying email addresses. The Ngram analyzer breaks words into even smaller tokens of a customized number of characters. Lucene also allows you to add and create new analyzers, and prioritize search results according to your business logic.
Aggregate one query’s results into a multitude of categories using facet queries.
You’ve probably seen facets while shopping online. Imagine you have a website for selling cars. You could display your catalogue divided by vehicle type, or by manufacturer. By gas mileage, or by safety features. Maybe you’d allow your user to define a price range – or why not several.
With a single facet query, you can organize data into all of these categories and numerical ranges at once, as well as list the number of results in each category. Your users can then mix and match facets until they find the perfect fit.
GPS technology has flooded us with endless geospatial data – but with spatial queries, you’ll never lose your bearings. You could find every cafe within a mile of a train station and sort them by closest first – but much more than that. Use one query to divide the world into custom WKT regions of any shape and size, then overlap them in any combination. Are you looking for a city? Or a pet cat with a microchip? Fine-tune the accuracy to your needs. The word “where” has never been so specific.
Separate words can become a sentence. Numbers can be plugged into calculations. Sequences can be sorted in a new order. Flat lists can be projected into hierarchies or networks. Do it all on the server side, and let your application relax.
When you have to load a long stream of documents, it helps to know which ones you want first. Unlike in other databases, the same index can let you sort data in one order just as easily as another order.
Results can be sorted ascending or descending, alphabetically, numerically, chronologically, and by Lucene index scores. Why not sort in two dimensions? If you have spatial data, you can order by distance. Need more power? Add or create new sorting logic. Like to be surprised? Sort random.
But the real power of this feature comes from combining multiple sorting orders, then sorting your sorting orders until they perfectly reflect your priorities.
Fetching related data
With includes, your results can be amplified by fetching additional related data – without making additional queries.
Sometimes your query depends on making another query. Like when you want to know someone’s phone number…but you need to check an email to remember their name first. This would normally take two round-trips to the server – often the most time consuming and expensive part of a query. So why not tell the server to fetch the email and also look up that phone number so they can both be sent at once? Two queries, at the cost of one.
By modeling your documents so they ‘know’ about each other, a simple query can fetch a lot more data. When you want to query that other data, it’s already here.
Aggregations use many documents to answer questions that no one document could, such as computing sums, averages, finding a maximum value, etc.
Our queries are great at aggregating data, but our Map-Reduce indexes can do you one better. For your heaviest and most complex aggregations, define a Map-Reduce pipeline on the server side so your results are ready long before you need them. Whenever data is added or modified, the index will keep the aggregation up to date. With a little preparation, your users will be able to sum a million documents as easily as they fetch one.