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,128 | Comments: 45,544

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.


  1. The low level interview question - 15 hours from now
  2. The worker pattern - 4 days from now

There are posts all the way to May 30, 2016


  1. The design of RavenDB 4.0 (14):
    26 May 2016 - The client side
  2. RavenDB 3.5 whirl wind tour (14):
    25 May 2016 - Got anything to declare, ya smuggler?
  3. Tasks for the new comer (2):
    15 Apr 2016 - Quartz.NET with RavenDB
  4. Code through the looking glass (5):
    18 Mar 2016 - And a linear search to rule them
  5. Find the bug (8):
    29 Feb 2016 - When you can't rely on your own identity
View all series



Main feed Feed Stats
Comments feed   Comments Feed Stats