在RavenDb文档中查询嵌套集合

时间:2018-05-30 21:18:48

标签: c# lucene ravendb

我有一个使用Lucene扩展的过滤方法,用于具有以下结构的Store文档列表:

 public class Store {
    public string Id { get; set; }
    public string Name { get; set; }
    public string Url { get; set; }
    public string Address { get; set; }
    public ICollection<Product> Products { get; set; }

  }

  public class Product {
      public string Name { get; set; }
      public double Price { get; set; }
  }

我的过滤方法:

    public IEnumerable<Store> Filter(string term = null)
    {
        var query = session.Advanced.DocumentQuery<Store>();

        if (!string.IsNullOrEmpty(term))
        {
            var search = $"*{term}*";
            var escapeQueryOptions = EscapeQueryOptions.AllowAllWildcards;

            query = query
                .Search(n => n.Name, search, escapeQueryOptions)
                .OrElse()
                .Search(n => n.Url, search, escapeQueryOptions)
                .OrElse()
                .Search(n => n.Address, search, escapeQueryOptions);
        }

        return query;
    }

现在我想按产品名称来过滤,但我无法弄清楚如何用lucene来表达。

0 个答案:

没有答案