Query RavenDB Product Catalog for Custom Product Specification for Custom Product Collection

This is a continuation of the project outlined in this matter.

I have the following model:

class Product {
  public string Id { get; set; }
  public string[] Specs { get; set; }
  public int CategoryId { get; set; }
}

The Specs array contains pairs of values โ€‹โ€‹for the name of the product specification, connected by a special character. For example, if a product is blue, the specification line will be โ€œColor-Blue.โ€ Presenting specifications in this way allows you to query products that have multiple specification values โ€‹โ€‹specified by the request. There are two main issues that I would like to support:

  • Get all products in a specific category.
  • Get all products in this category that have a set of specified specifications.

RavenDB. , , , - spec , . - spec , . # 1 :

class CategorySpecGroups {
    public int CategoryId { get; set; }
    public string Spec { get; set; }
    public int Count { get; set; }
}


public class SpecGroups_ByCategoryId : AbstractIndexCreationTask<Product, CategorySpecGroups>
{
    public SpecGroups_ByCategoryId()
    {
        this.Map = products => from product in products
                               where product.Specs != null
                               from spec in product.Specs
                               select new
                               {
                                   CategoryId = product.CategoryId,
                                   Spec = spec,
                                   Count = 1
                               };

        this.Reduce = results => from result in results
                                 group result by new { result.CategoryId, result.Spec } into g
                                 select new
                                 {
                                     CategoryId = g.Key.CategoryId,
                                     Spec = g.Key.Spec,
                                     Count = g.Sum(x => x.Count)
                                 };
    }
}

. , , , , , , -. SQL , . , , , , - 1000 . MongoDB group, . , .

RavenDB?

, - mapreduce, , , spec, , , , .

. , . , . .

, , Solr, .

2

, RavenDB (, , , Lucene , Solr). .

3

RavenDB , . , . , , - . 500 . 4500 , 4500 16 , 0,05 , . 6 . , 23 2 . . FacetedQueryRunner, Lucene , , , . , , , , , Lucene. MapReduce ( ) , , . .

+5
1

, RavenDB , FacetedQueryRunner . , . , , .

, , FacetSetup , "facets/category_123". , , ( ), . Ranges Facet FacetSetup, - FacetMode.Default.

FacetedQueryRunner. , , , , , , , . Lucene, , .

, , , , FacetSetup . , , - Ranges, FacetSetup, , . FacetSetup - .

FacetSetup, . , , , Solr- .

, , FacetSetup, , MapReduce , , , .

+3

All Articles