Ayende @ Rahien

My name is Oren Eini
Founder of Hibernating Rhinos LTD and RavenDB.
You can reach me by phone or email:


+972 52-548-6969

, @ Q c

Posts: 6,007 | Comments: 44,760

filter by tags archive

Raven Suggest

time to read 3 min | 457 words

Originally posted at 11/18/2010

image Since RavenDB’s indexing is based on Lucene, we get a lot of advantages. One of them is supporting suggestions.

What is the Raven Suggest feature?  Let us say that we give the user the option to perform some query, but the query that they sent us isn’t returning enough results (or non at all).

We can ask RavenDB to figure out what the user meant. Here is the code:

 var q = from user in session.Query<User>("Users/ByName")
         where user.Name == name
         select user;

Now, we can call q.FirstOrDefault() on this query, and see if we got any results. If we didn’t get a result, we can now ask RavenDB for help:

 var suggestionQueryResult = q.Suggest();
 Console.WriteLine("Did you mean?");
 foreach (var suggestion in suggestionQueryResult.Suggestions)
     Console.WriteLine("\t{0}", suggestion);

This will produce the following output:

Enter user name: oren
Found user: users/1
Enter user name: ore
Did you mean?
Enter user name: onre
Did you mean?

This is a nice little feature, which can really make a difference in terms of your application’s user experience.


Jason Meckley

It's awesome to see Raven coming into it's own. The feature set incorporated into Raven is really making this product stand out among the competition.

Julio Camps

Hi, where is located Suggest() method?

ex: q.Suggest();

I can not find it.

Please excuse my poor english, i am cuban engineer.

John Harman

Great feature, I presume it's running off something similar to Snowball.NET?

Ayende Rahien


You are probably looking at the stable branch, you should look at the unstable, that is where the new features are.

Ayende Rahien


No, it is based on Spell.NET


That's a nice feature. What I need in addition to this, is I need to query for all possible matches as the "suggest" is doing ... but in a query

Something like this :

var q = from user in session.Query <user("Users/ByName")

     where user.Name.SuggestedFrom(name)

     select user;

Is this doable ... ?

Ayende Rahien


You can certainly write a query that would do that, but why would you want to do this?


You know users sometimes misspell names ... I need to check for name uniques even if it is entered "wrong" and use one copy of a name ...

Can you suggest a way to query this ... or can we expect raven to have such feature built in ?

Ayende Rahien


You can query for each of the possible names, sure. Or combine them into a single query.

Not very useful, though.

Julio Camps

HI again :)

IN build 206, say that

Full support for suggestions, on both lucene & linq queries

But i can not find it :(, i must use a specific namespace ??

Where is located this feature?? You may post using clause for this sample? Thank's in advanced

Ayende Rahien


Is is there, as an extension method, you need to import the namespace Raven.Client.Linq

Comment preview

Comments have been closed on this topic.


No future posts left, oh my!


  1. Speaking (3):
    23 Sep 2015 - Build Stuff 2015 (Lithuania & Ukraine), Nov 18 - 24
  2. Production postmortem (11):
    22 Sep 2015 - The case of the Unicode Poo
  3. Technical observations from my wife (2):
    15 Sep 2015 - Disk speeds
  4. Find the bug (5):
    11 Sep 2015 - The concurrent memory buster
  5. Buffer allocation strategies (3):
    09 Sep 2015 - Bad usage patterns
View all series



Main feed Feed Stats
Comments feed   Comments Feed Stats