Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Queries++ in RavenDB: Gimme More Like This

DZone's Guide to

Queries++ in RavenDB: Gimme More Like This

Learn about a feature called More Like This, which tells you if there have been other instances of the same issue or similar ones in the past—as you're typing a bug report.

· Database Zone ·
Free Resource

RavenDB vs MongoDB: Which is Better? This White Paper compares the two leading NoSQL Document Databases on 9 features to find out which is the best solution for your next project.  


imageWhat do you do when you find something you like? If it's a favorite dish at a restaurant, you order it every time you go. But if this is something like a good book or a TV show, you’ll typically want to check out similar stuff to enjoy, as well. On a more serious note, if you are looking at a bug report, you might want to figure out if there have been other instances of the same issue or similar ones in the past — hopefully as you are typing the bug report.

The feature, in general, is called More Like This, and it is a nice way to smart-up your application. I’m going to use this blog as an example because More Like This usually requires a significant dataset to be meaningful. We are going to define the following index:

image

And configure the index to use Term Vectors as part of the indexing process:

image

Once this initial configuration is done, you can now go to RavenDB and ask it to suggest similar posts to an existing one. Here is how this is done:

image

This asks RavenDB to find posts similar to PR Review: Encapsulation stops at the assembly boundary, and the result is:

image

Note that you don’t have to specify an existing document, you can also send the values you want to match on directly:

image

And this will give you the same results!

Get comfortable using NoSQL in a free, self-directed learning course provided by RavenDB. Learn to create fully-functional real-world programs on NoSQL Databases. Register today.

Topics:
conditional queries ,query performance ,query hash ,data analytics ,database ,ravendb

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}