jvanrhyn
jvanrhyn

Reputation: 2824

RavenDB SelectMany not supported

I am trying to find one or more documents in RavenDB based on the values of a child collection.

I have the following classes

public class GoldenDocument
{
    public GoldenDocument()
    {
        LinkedDocuments = new List<LinkedDocument>();
        MergeMatchFields = new List<MergeMatchField>();
    }

    public string Id { get; set; }
    public Guid SourceRowId { get; set; }
    public List<MergeMatchField> MergeMatchFields { get; set; }
    public List<LinkedDocument> LinkedDocuments { get; set; }
}

And the class that is in the collection MergeMatchFields

public class MergeMatchField
{
    public string Id { get; set; }
    public Guid OriginId { get; set; }
    public string Name { get; set; }
    public MatchType MatchType { get; set; }
    public double MatchPerc { get; set; }
    public string Value { get; set; }
}

In a List<MergeFields> mergeFields collection I have values that is not stored in RavenDB yet. Values are compared to values in a RavenDB document for find if it is a possible match by executing the following query:

using (var session = documentStore.OpenSession())
{
    var docs = from gd in session.Query<GoldenDocument>()
                from mf in gd.MergeMatchFields
                from tf in mergeFields
                where mf.Name == tf.Name 
                && JaroWinklerCalculator.jaroWinkler(mf.Value, tf.Value) > .90d 
                && !string.IsNullOrEmpty(mf.Value)
                select gd;
}

I understand that ravenDB does not support SelectMany() so how would I go about getting the results from the Document store?

Upvotes: 0

Views: 392

Answers (1)

Ayende Rahien
Ayende Rahien

Reputation: 22956

Create an index for this that would output the values you want to query on. Note that you can't just execute arbitrary code the way you do here: JaroWinklerCalculator.jaroWinkler(mf.Value, tf.Value) > .90d

But you can use fuzzy queries, and they will do the same.

Upvotes: 1

Related Questions