How do I query children on RavenDB?

I am trying to query children on RavenDB. Nested in .NET, text search works, but WhereBetweenOrEqual, WhereGreaterThan, WhereLessThan doesn't work.

My code:

public class Document
{
    public string Id { set; get; }
    public IEnumerable<Attribute> Attributes { set; get; } 
}

public class Attribute
{
    public string Key { set; get; }
    public object Value { set; get; }
}

      

Abstract indexing class

public class Document_ByAttribute : AbstractIndexCreationTask<Document>
{
    public Document_ByAttribute()
    {
        Map = documents => from doc in documents
                          select new
                          {
                              _ = doc.Attributes
                                 .Select(attribute =>
                                     CreateField(attribute.Key, attribute.Value, false, true))
                          };
    }
}

      

It works

    public ActionResult Filter(string id)
    {
        var doc = _Session.Advanced.LuceneQuery<Document>("Document/ByAttribute").Search("Title", "*" + id + "*").ToList();
        return Json(doc, JsonRequestBehavior.AllowGet); 
    }

      

This feature does not work

    public ActionResult Price_Range(decimal min = 0, decimal max = 99999999)
    {
        var doc = _Session.Advanced.LuceneQuery<Document>("Document/ByAttribute").WhereBetweenOrEqual("Price", min, max).ToList();
        return Json(doc, JsonRequestBehavior.AllowGet); 
    }

      

I've tried everything. I did not succeed. Please help me. How to do it?

Thanks in advance.

+3


source to share


1 answer


The likely problem is the types. You are passing in a decimal number, but the value is interpreted in some other way on the server (probably float or int). Make sure they match.



0


source







All Articles