Queries++ in RavenDBGimme more like this

time to read 2 min | 340 words

imageWhat do you do when you find something you like? If this a favorite dish at a restaurant, you keep order it forever and ever. 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 has 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 the example, because More Like This usually requires a significant data set 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 ask 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.

More posts in "Queries++ in RavenDB" series:

  1. (18 Dec 2017) Spatial searches
  2. (15 Dec 2017) I suggest you can do better
  3. (11 Dec 2017) Gimme more like this
  4. (07 Dec 2017) Facets of information