I'm trying to think more about this before I try to crowbar this into
Raven.Database. I first thought this would be similar to the
SpatialIndex, but quickly realized that this is an entirely different
animal.
The SpatialIndex helps you create an index that Spatial.Net can use.
In this case we already should have (or easily create) an index using
the facilities already in Raven. The real problem lies in the Query.
It almost seems like you don't really need a "Special" index for this
to work. This would work fine:
// dictionary Index (Name = Players)
from player in docs.Players
select new { player.Name }
The Client API would need to be altered in some form, maybe like
below?
// Client API
SuggestionQuery("DictionaryIndex").Suggest(term, indexFieldName,
numOfSuggestions = 10, accuracy = 0.5f)
SuggestionQuery("Players").Suggest("John", "Name", numOfSuggestions =
10, accuracy = 0.5f)
SuggestionQuery<Player>("Players").Suggest( p => p.Name == "John",
numOfSuggestions = 10, accuracy = 0.5f)
All you need is for Raven to scan an entire index using the
SpellChecker.Net library, then spit back a Json/C# object that matches
the following.
public class SuggestionResult
{
// The term entered by the end user
public string Term { get; }
// The dictionary index you searched for suggestions
public string IndexName {get;}
// The lucene index field that you searched on
public string Field { get; }
// The suggestions based on the term and dictionary
public IEnumerable<string> Suggestions { get; }
}
It feels like to me that I should create a new Query type, and get the
Raven.Database.QueryRunner class to execute the new SuggestionQuery
and then pump the results into RemoteQueryResults.Results on line 84
of QueryRunner.cs.
Any Suggestions? Have I missed something fundemental?