Example #1
0
        public void CanGetFacets()
        {
            using (var store = GetDocumentStore())
            {
                var index = new CameraCost();
                index.Execute(store);

                using (var commands = store.Commands())
                {
                    for (var i = 0; i < 10; i++)
                    {
                        commands.Put(
                            "cameras/" + i,
                            null,
                            new Camera
                        {
                            Id           = "cameras/" + i,
                            Manufacturer = i % 2 == 0 ? "Manufacturer1" : "Manufacturer2",
                            Cost         = i * 100D,
                            Megapixels   = i * 1D
                        },
                            new Dictionary <string, object> {
                            { "@collection", "Cameras" }
                        });
                    }


                    WaitForIndexing(store);

                    var facets = new List <Facet>
                    {
                        new Facet
                        {
                            FieldName = "Manufacturer"
                        }
                    };

                    var rangeFacets = new List <RangeFacet>
                    {
                        new RangeFacet
                        {
                            Ranges =
                            {
                                "Cost <= 200",
                                "Cost >= 300 and Cost <= 400",
                                "Cost >= 500 and Cost <= 600",
                                "Cost >= 700 and Cost <= 800",
                                "Cost >= 900"
                            }
                        },
                        new RangeFacet
                        {
                            Ranges =
                            {
                                "Megapixels <= 3",
                                "Megapixels >= 4 and Megapixels <= 7",
                                "Megapixels >= 8 and Megapixels <= 10",
                                "Megapixels >= 11",
                            }
                        }
                    };


                    commands.Put(
                        "facets/CameraFacets",
                        null,
                        new FacetSetup {
                        Id = "facets/CameraFacets", Facets = facets, RangeFacets = rangeFacets
                    },
                        null);

                    WaitForIndexing(store);

                    using (var session = store.OpenSession())
                    {
                        var facetResults = session
                                           .Query <Camera, CameraCost>()
                                           .AggregateUsing("facets/CameraFacets")
                                           .Execute();

                        Assert.Equal(3, facetResults.Count);

                        Assert.Equal(2, facetResults["Manufacturer"].Values.Count);
                        Assert.Equal("manufacturer1", facetResults["Manufacturer"].Values[0].Range);
                        Assert.Equal(5, facetResults["Manufacturer"].Values[0].Count);
                        Assert.Equal("manufacturer2", facetResults["Manufacturer"].Values[1].Range);
                        Assert.Equal(5, facetResults["Manufacturer"].Values[1].Count);

                        Assert.Equal(5, facetResults["Cost"].Values.Count);
                        Assert.Equal("Cost <= 200", facetResults["Cost"].Values[0].Range);
                        Assert.Equal(3, facetResults["Cost"].Values[0].Count);
                        Assert.Equal("Cost >= 300 and Cost <= 400", facetResults["Cost"].Values[1].Range);
                        Assert.Equal(2, facetResults["Cost"].Values[1].Count);
                        Assert.Equal("Cost >= 500 and Cost <= 600", facetResults["Cost"].Values[2].Range);
                        Assert.Equal(2, facetResults["Cost"].Values[2].Count);
                        Assert.Equal("Cost >= 700 and Cost <= 800", facetResults["Cost"].Values[3].Range);
                        Assert.Equal(2, facetResults["Cost"].Values[3].Count);
                        Assert.Equal("Cost >= 900", facetResults["Cost"].Values[4].Range);
                        Assert.Equal(1, facetResults["Cost"].Values[4].Count);

                        Assert.Equal(4, facetResults["Megapixels"].Values.Count);
                        Assert.Equal("Megapixels <= 3", facetResults["Megapixels"].Values[0].Range);
                        Assert.Equal(4, facetResults["Megapixels"].Values[0].Count);
                        Assert.Equal("Megapixels >= 4 and Megapixels <= 7", facetResults["Megapixels"].Values[1].Range);
                        Assert.Equal(4, facetResults["Megapixels"].Values[1].Count);
                        Assert.Equal("Megapixels >= 8 and Megapixels <= 10", facetResults["Megapixels"].Values[2].Range);
                        Assert.Equal(2, facetResults["Megapixels"].Values[2].Count);
                        Assert.Equal("Megapixels >= 11", facetResults["Megapixels"].Values[3].Range);
                        Assert.Equal(0, facetResults["Megapixels"].Values[3].Count);
                    }

                    using (var session = store.OpenSession())
                    {
                        var r1 = session.Query <Camera, CameraCost>()
                                 .Where(x => x.Cost < 200)
                                 .AggregateUsing("facets/CameraFacets")
                                 .Execute();

                        var r2 = session.Query <Camera, CameraCost>()
                                 .Where(x => x.Megapixels < 3)
                                 .AggregateUsing("facets/CameraFacets")
                                 .Execute();

                        var multiFacetResults = new[] { r1, r2 };

                        Assert.Equal(3, multiFacetResults[0].Count);

                        Assert.Equal(2, multiFacetResults[0]["Manufacturer"].Values.Count);
                        Assert.Equal("manufacturer1", multiFacetResults[0]["Manufacturer"].Values[0].Range);
                        Assert.Equal(1, multiFacetResults[0]["Manufacturer"].Values[0].Count);
                        Assert.Equal("manufacturer2", multiFacetResults[0]["Manufacturer"].Values[1].Range);
                        Assert.Equal(1, multiFacetResults[0]["Manufacturer"].Values[1].Count);

                        Assert.Equal(5, multiFacetResults[0]["Cost"].Values.Count);
                        Assert.Equal("Cost <= 200", multiFacetResults[0]["Cost"].Values[0].Range);
                        Assert.Equal(2, multiFacetResults[0]["Cost"].Values[0].Count);
                        Assert.Equal("Cost >= 300 and Cost <= 400", multiFacetResults[0]["Cost"].Values[1].Range);
                        Assert.Equal(0, multiFacetResults[0]["Cost"].Values[1].Count);
                        Assert.Equal("Cost >= 500 and Cost <= 600", multiFacetResults[0]["Cost"].Values[2].Range);
                        Assert.Equal(0, multiFacetResults[0]["Cost"].Values[2].Count);
                        Assert.Equal("Cost >= 700 and Cost <= 800", multiFacetResults[0]["Cost"].Values[3].Range);
                        Assert.Equal(0, multiFacetResults[0]["Cost"].Values[3].Count);
                        Assert.Equal("Cost >= 900", multiFacetResults[0]["Cost"].Values[4].Range);
                        Assert.Equal(0, multiFacetResults[0]["Cost"].Values[4].Count);

                        Assert.Equal(4, multiFacetResults[0]["Megapixels"].Values.Count);
                        Assert.Equal("Megapixels <= 3", multiFacetResults[0]["Megapixels"].Values[0].Range);
                        Assert.Equal(2, multiFacetResults[0]["Megapixels"].Values[0].Count);
                        Assert.Equal("Megapixels >= 4 and Megapixels <= 7", multiFacetResults[0]["Megapixels"].Values[1].Range);
                        Assert.Equal(0, multiFacetResults[0]["Megapixels"].Values[1].Count);
                        Assert.Equal("Megapixels >= 8 and Megapixels <= 10", multiFacetResults[0]["Megapixels"].Values[2].Range);
                        Assert.Equal(0, multiFacetResults[0]["Megapixels"].Values[2].Count);
                        Assert.Equal("Megapixels >= 11", multiFacetResults[0]["Megapixels"].Values[3].Range);
                        Assert.Equal(0, multiFacetResults[0]["Megapixels"].Values[3].Count);


                        Assert.Equal(3, multiFacetResults[1].Count);

                        Assert.Equal(2, multiFacetResults[1]["Manufacturer"].Values.Count);
                        Assert.Equal("manufacturer1", multiFacetResults[1]["Manufacturer"].Values[0].Range);
                        Assert.Equal(2, multiFacetResults[1]["Manufacturer"].Values[0].Count);
                        Assert.Equal("manufacturer2", multiFacetResults[1]["Manufacturer"].Values[1].Range);
                        Assert.Equal(1, multiFacetResults[1]["Manufacturer"].Values[1].Count);

                        Assert.Equal(5, multiFacetResults[1]["Cost"].Values.Count);
                        Assert.Equal("Cost <= 200", multiFacetResults[1]["Cost"].Values[0].Range);
                        Assert.Equal(3, multiFacetResults[1]["Cost"].Values[0].Count);
                        Assert.Equal("Cost >= 300 and Cost <= 400", multiFacetResults[1]["Cost"].Values[1].Range);
                        Assert.Equal(0, multiFacetResults[1]["Cost"].Values[1].Count);
                        Assert.Equal("Cost >= 500 and Cost <= 600", multiFacetResults[1]["Cost"].Values[2].Range);
                        Assert.Equal(0, multiFacetResults[1]["Cost"].Values[2].Count);
                        Assert.Equal("Cost >= 700 and Cost <= 800", multiFacetResults[1]["Cost"].Values[3].Range);
                        Assert.Equal(0, multiFacetResults[1]["Cost"].Values[3].Count);
                        Assert.Equal("Cost >= 900", multiFacetResults[1]["Cost"].Values[4].Range);
                        Assert.Equal(0, multiFacetResults[1]["Cost"].Values[4].Count);

                        Assert.Equal(4, multiFacetResults[1]["Megapixels"].Values.Count);
                        Assert.Equal("Megapixels <= 3", multiFacetResults[1]["Megapixels"].Values[0].Range);
                        Assert.Equal(3, multiFacetResults[1]["Megapixels"].Values[0].Count);
                        Assert.Equal("Megapixels >= 4 and Megapixels <= 7", multiFacetResults[1]["Megapixels"].Values[1].Range);
                        Assert.Equal(0, multiFacetResults[1]["Megapixels"].Values[1].Count);
                        Assert.Equal("Megapixels >= 8 and Megapixels <= 10", multiFacetResults[1]["Megapixels"].Values[2].Range);
                        Assert.Equal(0, multiFacetResults[1]["Megapixels"].Values[2].Count);
                        Assert.Equal("Megapixels >= 11", multiFacetResults[1]["Megapixels"].Values[3].Range);
                        Assert.Equal(0, multiFacetResults[1]["Megapixels"].Values[3].Count);
                    }
                }
            }
        }
Example #2
0
        public void CanGetFacets()
        {
            using (var store = GetDocumentStore())
            {
                var index = new CameraCost();
                index.Execute(store);

                for (int i = 0; i < 10; i++)
                {
                    store.DatabaseCommands.Put(
                        "cameras/"+i, 
                        null, 
                        RavenJObject.FromObject(new Camera
                        {
                            Id = "cameras/" + i,
                            Manufacturer = i % 2 == 0 ? "Manufacturer1" : "Manufacturer2",
                            Cost = i * 100D,
                            Megapixels = i * 1D
                        }),
                        new RavenJObject { { "Raven-Entity-Name", "Cameras" } });
                }
                WaitForIndexing(store);

                var facets = new List<Facet>
                {
                    new Facet 
                    {
                        Name = "Manufacturer"
                    },
                    new Facet 
                    {
                        Name = "Cost_Range",
                        Mode = FacetMode.Ranges,
                        Ranges = 
                        {
                            "[NULL TO Dx200.0]",
                            "[Dx300.0 TO Dx400.0]",
                            "[Dx500.0 TO Dx600.0]",
                            "[Dx700.0 TO Dx800.0]",
                            "[Dx900.0 TO NULL]"
                        }
                    },
                    new Facet 
                    {
                        Name = "Megapixels_Range",
                        Mode = FacetMode.Ranges,
                        Ranges = 
                        {
                            "[NULL TO Dx3.0]",
                            "[Dx4.0 TO Dx7.0]",
                            "[Dx8.0 TO Dx10.0]",
                            "[Dx11.0 TO NULL]"
                        }
                    }
                };
                store.DatabaseCommands.Put(
                    "facets/CameraFacets", 
                    null, 
                    RavenJObject.FromObject(new FacetSetup { Id = "facets/CameraFacets", Facets = facets }), 
                    new RavenJObject());
                WaitForIndexing(store);

                var facetResults = store.DatabaseCommands.GetFacets(index.IndexName, new IndexQuery{Query=""}, "facets/CameraFacets");

                Assert.Equal(3, facetResults.Results.Count);

                Assert.Equal(2, facetResults.Results["Manufacturer"].Values.Count);
                Assert.Equal("manufacturer1", facetResults.Results["Manufacturer"].Values[0].Range);
                Assert.Equal(5, facetResults.Results["Manufacturer"].Values[0].Hits);
                Assert.Equal("manufacturer2", facetResults.Results["Manufacturer"].Values[1].Range);
                Assert.Equal(5, facetResults.Results["Manufacturer"].Values[1].Hits);

                Assert.Equal(5, facetResults.Results["Cost_Range"].Values.Count);
                Assert.Equal("[NULL TO Dx200.0]", facetResults.Results["Cost_Range"].Values[0].Range);
                Assert.Equal(3, facetResults.Results["Cost_Range"].Values[0].Hits);
                Assert.Equal("[Dx300.0 TO Dx400.0]", facetResults.Results["Cost_Range"].Values[1].Range);
                Assert.Equal(2, facetResults.Results["Cost_Range"].Values[1].Hits);
                Assert.Equal("[Dx500.0 TO Dx600.0]", facetResults.Results["Cost_Range"].Values[2].Range);
                Assert.Equal(2, facetResults.Results["Cost_Range"].Values[2].Hits);
                Assert.Equal("[Dx700.0 TO Dx800.0]", facetResults.Results["Cost_Range"].Values[3].Range);
                Assert.Equal(2, facetResults.Results["Cost_Range"].Values[3].Hits);
                Assert.Equal("[Dx900.0 TO NULL]", facetResults.Results["Cost_Range"].Values[4].Range);
                Assert.Equal(1, facetResults.Results["Cost_Range"].Values[4].Hits);

                Assert.Equal(4, facetResults.Results["Megapixels_Range"].Values.Count);
                Assert.Equal("[NULL TO Dx3.0]", facetResults.Results["Megapixels_Range"].Values[0].Range);
                Assert.Equal(4, facetResults.Results["Megapixels_Range"].Values[0].Hits);
                Assert.Equal("[Dx4.0 TO Dx7.0]", facetResults.Results["Megapixels_Range"].Values[1].Range);
                Assert.Equal(4, facetResults.Results["Megapixels_Range"].Values[1].Hits);
                Assert.Equal("[Dx8.0 TO Dx10.0]", facetResults.Results["Megapixels_Range"].Values[2].Range);
                Assert.Equal(2, facetResults.Results["Megapixels_Range"].Values[2].Hits);
                Assert.Equal("[Dx11.0 TO NULL]", facetResults.Results["Megapixels_Range"].Values[3].Range);
                Assert.Equal(0, facetResults.Results["Megapixels_Range"].Values[3].Hits);


                var multiFacetResults = store.DatabaseCommands.GetMultiFacets(new FacetQuery[] 
                {
                    new FacetQuery 
                    { 
                        IndexName = index.IndexName, 
                        Query = new IndexQuery 
                        { 
                            Query = "Cost:{NULL TO 200}" 
                        }, 
                        FacetSetupDoc = "facets/CameraFacets" 
                    },
                    new FacetQuery 
                    { 
                        IndexName = index.IndexName, 
                        Query = new IndexQuery 
                        { 
                            Query = "Megapixels:{NULL TO 3}" 
                        }, 
                        FacetSetupDoc = "facets/CameraFacets" 
                    }
                });

                Assert.Equal(3, multiFacetResults[0].Results.Count);

                Assert.Equal(2, multiFacetResults[0].Results["Manufacturer"].Values.Count);
                Assert.Equal("manufacturer1", multiFacetResults[0].Results["Manufacturer"].Values[0].Range);
                Assert.Equal(1, multiFacetResults[0].Results["Manufacturer"].Values[0].Hits);
                Assert.Equal("manufacturer2", multiFacetResults[0].Results["Manufacturer"].Values[1].Range);
                Assert.Equal(1, multiFacetResults[0].Results["Manufacturer"].Values[1].Hits);

                Assert.Equal(5, multiFacetResults[0].Results["Cost_Range"].Values.Count);
                Assert.Equal("[NULL TO Dx200.0]", multiFacetResults[0].Results["Cost_Range"].Values[0].Range);
                Assert.Equal(2, multiFacetResults[0].Results["Cost_Range"].Values[0].Hits);
                Assert.Equal("[Dx300.0 TO Dx400.0]", multiFacetResults[0].Results["Cost_Range"].Values[1].Range);
                Assert.Equal(0, multiFacetResults[0].Results["Cost_Range"].Values[1].Hits);
                Assert.Equal("[Dx500.0 TO Dx600.0]", multiFacetResults[0].Results["Cost_Range"].Values[2].Range);
                Assert.Equal(0, multiFacetResults[0].Results["Cost_Range"].Values[2].Hits);
                Assert.Equal("[Dx700.0 TO Dx800.0]", multiFacetResults[0].Results["Cost_Range"].Values[3].Range);
                Assert.Equal(0, multiFacetResults[0].Results["Cost_Range"].Values[3].Hits);
                Assert.Equal("[Dx900.0 TO NULL]", multiFacetResults[0].Results["Cost_Range"].Values[4].Range);
                Assert.Equal(0, multiFacetResults[0].Results["Cost_Range"].Values[4].Hits);

                Assert.Equal(4, multiFacetResults[0].Results["Megapixels_Range"].Values.Count);
                Assert.Equal("[NULL TO Dx3.0]", multiFacetResults[0].Results["Megapixels_Range"].Values[0].Range);
                Assert.Equal(2, multiFacetResults[0].Results["Megapixels_Range"].Values[0].Hits);
                Assert.Equal("[Dx4.0 TO Dx7.0]", multiFacetResults[0].Results["Megapixels_Range"].Values[1].Range);
                Assert.Equal(0, multiFacetResults[0].Results["Megapixels_Range"].Values[1].Hits);
                Assert.Equal("[Dx8.0 TO Dx10.0]", multiFacetResults[0].Results["Megapixels_Range"].Values[2].Range);
                Assert.Equal(0, multiFacetResults[0].Results["Megapixels_Range"].Values[2].Hits);
                Assert.Equal("[Dx11.0 TO NULL]", multiFacetResults[0].Results["Megapixels_Range"].Values[3].Range);
                Assert.Equal(0, multiFacetResults[0].Results["Megapixels_Range"].Values[3].Hits);


                Assert.Equal(3, multiFacetResults[1].Results.Count);

                Assert.Equal(2, multiFacetResults[1].Results["Manufacturer"].Values.Count);
                Assert.Equal("manufacturer1", multiFacetResults[1].Results["Manufacturer"].Values[0].Range);
                Assert.Equal(2, multiFacetResults[1].Results["Manufacturer"].Values[0].Hits);
                Assert.Equal("manufacturer2", multiFacetResults[1].Results["Manufacturer"].Values[1].Range);
                Assert.Equal(1, multiFacetResults[1].Results["Manufacturer"].Values[1].Hits);

                Assert.Equal(5, multiFacetResults[1].Results["Cost_Range"].Values.Count);
                Assert.Equal("[NULL TO Dx200.0]", multiFacetResults[1].Results["Cost_Range"].Values[0].Range);
                Assert.Equal(3, multiFacetResults[1].Results["Cost_Range"].Values[0].Hits);
                Assert.Equal("[Dx300.0 TO Dx400.0]", multiFacetResults[1].Results["Cost_Range"].Values[1].Range);
                Assert.Equal(0, multiFacetResults[1].Results["Cost_Range"].Values[1].Hits);
                Assert.Equal("[Dx500.0 TO Dx600.0]", multiFacetResults[1].Results["Cost_Range"].Values[2].Range);
                Assert.Equal(0, multiFacetResults[1].Results["Cost_Range"].Values[2].Hits);
                Assert.Equal("[Dx700.0 TO Dx800.0]", multiFacetResults[1].Results["Cost_Range"].Values[3].Range);
                Assert.Equal(0, multiFacetResults[1].Results["Cost_Range"].Values[3].Hits);
                Assert.Equal("[Dx900.0 TO NULL]", multiFacetResults[1].Results["Cost_Range"].Values[4].Range);
                Assert.Equal(0, multiFacetResults[1].Results["Cost_Range"].Values[4].Hits);

                Assert.Equal(4, multiFacetResults[1].Results["Megapixels_Range"].Values.Count);
                Assert.Equal("[NULL TO Dx3.0]", multiFacetResults[1].Results["Megapixels_Range"].Values[0].Range);
                Assert.Equal(3, multiFacetResults[1].Results["Megapixels_Range"].Values[0].Hits);
                Assert.Equal("[Dx4.0 TO Dx7.0]", multiFacetResults[1].Results["Megapixels_Range"].Values[1].Range);
                Assert.Equal(0, multiFacetResults[1].Results["Megapixels_Range"].Values[1].Hits);
                Assert.Equal("[Dx8.0 TO Dx10.0]", multiFacetResults[1].Results["Megapixels_Range"].Values[2].Range);
                Assert.Equal(0, multiFacetResults[1].Results["Megapixels_Range"].Values[2].Hits);
                Assert.Equal("[Dx11.0 TO NULL]", multiFacetResults[1].Results["Megapixels_Range"].Values[3].Range);
                Assert.Equal(0, multiFacetResults[1].Results["Megapixels_Range"].Values[3].Hits);
            }
        }
Example #3
0
        public void CanGetFacets()
        {
            using (var store = GetDocumentStore())
            {
                var index = new CameraCost();
                index.Execute(store);

                for (int i = 0; i < 10; i++)
                {
                    store.DatabaseCommands.Put(
                        "cameras/" + i,
                        null,
                        RavenJObject.FromObject(new Camera
                    {
                        Id           = "cameras/" + i,
                        Manufacturer = i % 2 == 0 ? "Manufacturer1" : "Manufacturer2",
                        Cost         = i * 100D,
                        Megapixels   = i * 1D
                    }),
                        new RavenJObject {
                        { "Raven-Entity-Name", "Cameras" }
                    });
                }
                WaitForIndexing(store);

                var facets = new List <Facet>
                {
                    new Facet
                    {
                        Name = "Manufacturer"
                    },
                    new Facet
                    {
                        Name   = "Cost_Range",
                        Mode   = FacetMode.Ranges,
                        Ranges =
                        {
                            "[NULL TO Dx200.0]",
                            "[Dx300.0 TO Dx400.0]",
                            "[Dx500.0 TO Dx600.0]",
                            "[Dx700.0 TO Dx800.0]",
                            "[Dx900.0 TO NULL]"
                        }
                    },
                    new Facet
                    {
                        Name   = "Megapixels_Range",
                        Mode   = FacetMode.Ranges,
                        Ranges =
                        {
                            "[NULL TO Dx3.0]",
                            "[Dx4.0 TO Dx7.0]",
                            "[Dx8.0 TO Dx10.0]",
                            "[Dx11.0 TO NULL]"
                        }
                    }
                };
                store.DatabaseCommands.Put(
                    "facets/CameraFacets",
                    null,
                    RavenJObject.FromObject(new FacetSetup {
                    Id = "facets/CameraFacets", Facets = facets
                }),
                    new RavenJObject());
                WaitForIndexing(store);

                var facetResults = store.DatabaseCommands.GetFacets(index.IndexName, new IndexQuery {
                    Query = ""
                }, "facets/CameraFacets");

                Assert.Equal(3, facetResults.Results.Count);

                Assert.Equal(2, facetResults.Results["Manufacturer"].Values.Count);
                Assert.Equal("manufacturer1", facetResults.Results["Manufacturer"].Values[0].Range);
                Assert.Equal(5, facetResults.Results["Manufacturer"].Values[0].Hits);
                Assert.Equal("manufacturer2", facetResults.Results["Manufacturer"].Values[1].Range);
                Assert.Equal(5, facetResults.Results["Manufacturer"].Values[1].Hits);

                Assert.Equal(5, facetResults.Results["Cost_Range"].Values.Count);
                Assert.Equal("[NULL TO Dx200.0]", facetResults.Results["Cost_Range"].Values[0].Range);
                Assert.Equal(3, facetResults.Results["Cost_Range"].Values[0].Hits);
                Assert.Equal("[Dx300.0 TO Dx400.0]", facetResults.Results["Cost_Range"].Values[1].Range);
                Assert.Equal(2, facetResults.Results["Cost_Range"].Values[1].Hits);
                Assert.Equal("[Dx500.0 TO Dx600.0]", facetResults.Results["Cost_Range"].Values[2].Range);
                Assert.Equal(2, facetResults.Results["Cost_Range"].Values[2].Hits);
                Assert.Equal("[Dx700.0 TO Dx800.0]", facetResults.Results["Cost_Range"].Values[3].Range);
                Assert.Equal(2, facetResults.Results["Cost_Range"].Values[3].Hits);
                Assert.Equal("[Dx900.0 TO NULL]", facetResults.Results["Cost_Range"].Values[4].Range);
                Assert.Equal(1, facetResults.Results["Cost_Range"].Values[4].Hits);

                Assert.Equal(4, facetResults.Results["Megapixels_Range"].Values.Count);
                Assert.Equal("[NULL TO Dx3.0]", facetResults.Results["Megapixels_Range"].Values[0].Range);
                Assert.Equal(4, facetResults.Results["Megapixels_Range"].Values[0].Hits);
                Assert.Equal("[Dx4.0 TO Dx7.0]", facetResults.Results["Megapixels_Range"].Values[1].Range);
                Assert.Equal(4, facetResults.Results["Megapixels_Range"].Values[1].Hits);
                Assert.Equal("[Dx8.0 TO Dx10.0]", facetResults.Results["Megapixels_Range"].Values[2].Range);
                Assert.Equal(2, facetResults.Results["Megapixels_Range"].Values[2].Hits);
                Assert.Equal("[Dx11.0 TO NULL]", facetResults.Results["Megapixels_Range"].Values[3].Range);
                Assert.Equal(0, facetResults.Results["Megapixels_Range"].Values[3].Hits);


                var multiFacetResults = store.DatabaseCommands.GetMultiFacets(new FacetQuery[]
                {
                    new FacetQuery
                    {
                        IndexName = index.IndexName,
                        Query     = new IndexQuery
                        {
                            Query = "Cost:{NULL TO 200}"
                        },
                        FacetSetupDoc = "facets/CameraFacets"
                    },
                    new FacetQuery
                    {
                        IndexName = index.IndexName,
                        Query     = new IndexQuery
                        {
                            Query = "Megapixels:{NULL TO 3}"
                        },
                        FacetSetupDoc = "facets/CameraFacets"
                    }
                });

                Assert.Equal(3, multiFacetResults[0].Results.Count);

                Assert.Equal(2, multiFacetResults[0].Results["Manufacturer"].Values.Count);
                Assert.Equal("manufacturer1", multiFacetResults[0].Results["Manufacturer"].Values[0].Range);
                Assert.Equal(1, multiFacetResults[0].Results["Manufacturer"].Values[0].Hits);
                Assert.Equal("manufacturer2", multiFacetResults[0].Results["Manufacturer"].Values[1].Range);
                Assert.Equal(1, multiFacetResults[0].Results["Manufacturer"].Values[1].Hits);

                Assert.Equal(5, multiFacetResults[0].Results["Cost_Range"].Values.Count);
                Assert.Equal("[NULL TO Dx200.0]", multiFacetResults[0].Results["Cost_Range"].Values[0].Range);
                Assert.Equal(2, multiFacetResults[0].Results["Cost_Range"].Values[0].Hits);
                Assert.Equal("[Dx300.0 TO Dx400.0]", multiFacetResults[0].Results["Cost_Range"].Values[1].Range);
                Assert.Equal(0, multiFacetResults[0].Results["Cost_Range"].Values[1].Hits);
                Assert.Equal("[Dx500.0 TO Dx600.0]", multiFacetResults[0].Results["Cost_Range"].Values[2].Range);
                Assert.Equal(0, multiFacetResults[0].Results["Cost_Range"].Values[2].Hits);
                Assert.Equal("[Dx700.0 TO Dx800.0]", multiFacetResults[0].Results["Cost_Range"].Values[3].Range);
                Assert.Equal(0, multiFacetResults[0].Results["Cost_Range"].Values[3].Hits);
                Assert.Equal("[Dx900.0 TO NULL]", multiFacetResults[0].Results["Cost_Range"].Values[4].Range);
                Assert.Equal(0, multiFacetResults[0].Results["Cost_Range"].Values[4].Hits);

                Assert.Equal(4, multiFacetResults[0].Results["Megapixels_Range"].Values.Count);
                Assert.Equal("[NULL TO Dx3.0]", multiFacetResults[0].Results["Megapixels_Range"].Values[0].Range);
                Assert.Equal(2, multiFacetResults[0].Results["Megapixels_Range"].Values[0].Hits);
                Assert.Equal("[Dx4.0 TO Dx7.0]", multiFacetResults[0].Results["Megapixels_Range"].Values[1].Range);
                Assert.Equal(0, multiFacetResults[0].Results["Megapixels_Range"].Values[1].Hits);
                Assert.Equal("[Dx8.0 TO Dx10.0]", multiFacetResults[0].Results["Megapixels_Range"].Values[2].Range);
                Assert.Equal(0, multiFacetResults[0].Results["Megapixels_Range"].Values[2].Hits);
                Assert.Equal("[Dx11.0 TO NULL]", multiFacetResults[0].Results["Megapixels_Range"].Values[3].Range);
                Assert.Equal(0, multiFacetResults[0].Results["Megapixels_Range"].Values[3].Hits);


                Assert.Equal(3, multiFacetResults[1].Results.Count);

                Assert.Equal(2, multiFacetResults[1].Results["Manufacturer"].Values.Count);
                Assert.Equal("manufacturer1", multiFacetResults[1].Results["Manufacturer"].Values[0].Range);
                Assert.Equal(2, multiFacetResults[1].Results["Manufacturer"].Values[0].Hits);
                Assert.Equal("manufacturer2", multiFacetResults[1].Results["Manufacturer"].Values[1].Range);
                Assert.Equal(1, multiFacetResults[1].Results["Manufacturer"].Values[1].Hits);

                Assert.Equal(5, multiFacetResults[1].Results["Cost_Range"].Values.Count);
                Assert.Equal("[NULL TO Dx200.0]", multiFacetResults[1].Results["Cost_Range"].Values[0].Range);
                Assert.Equal(3, multiFacetResults[1].Results["Cost_Range"].Values[0].Hits);
                Assert.Equal("[Dx300.0 TO Dx400.0]", multiFacetResults[1].Results["Cost_Range"].Values[1].Range);
                Assert.Equal(0, multiFacetResults[1].Results["Cost_Range"].Values[1].Hits);
                Assert.Equal("[Dx500.0 TO Dx600.0]", multiFacetResults[1].Results["Cost_Range"].Values[2].Range);
                Assert.Equal(0, multiFacetResults[1].Results["Cost_Range"].Values[2].Hits);
                Assert.Equal("[Dx700.0 TO Dx800.0]", multiFacetResults[1].Results["Cost_Range"].Values[3].Range);
                Assert.Equal(0, multiFacetResults[1].Results["Cost_Range"].Values[3].Hits);
                Assert.Equal("[Dx900.0 TO NULL]", multiFacetResults[1].Results["Cost_Range"].Values[4].Range);
                Assert.Equal(0, multiFacetResults[1].Results["Cost_Range"].Values[4].Hits);

                Assert.Equal(4, multiFacetResults[1].Results["Megapixels_Range"].Values.Count);
                Assert.Equal("[NULL TO Dx3.0]", multiFacetResults[1].Results["Megapixels_Range"].Values[0].Range);
                Assert.Equal(3, multiFacetResults[1].Results["Megapixels_Range"].Values[0].Hits);
                Assert.Equal("[Dx4.0 TO Dx7.0]", multiFacetResults[1].Results["Megapixels_Range"].Values[1].Range);
                Assert.Equal(0, multiFacetResults[1].Results["Megapixels_Range"].Values[1].Hits);
                Assert.Equal("[Dx8.0 TO Dx10.0]", multiFacetResults[1].Results["Megapixels_Range"].Values[2].Range);
                Assert.Equal(0, multiFacetResults[1].Results["Megapixels_Range"].Values[2].Hits);
                Assert.Equal("[Dx11.0 TO NULL]", multiFacetResults[1].Results["Megapixels_Range"].Values[3].Range);
                Assert.Equal(0, multiFacetResults[1].Results["Megapixels_Range"].Values[3].Hits);
            }
        }
Example #4
0
        public async Task UsingToListOnRawFacetQueryShouldThrow()
        {
            using (var store = GetDocumentStore())
            {
                var index = new CameraCost();
                index.Execute(store);

                using (var commands = store.Commands())
                {
                    var facets = new List <Facet>
                    {
                        new()
                        {
                            FieldName = "Manufacturer"
                        }
                    };

                    var rangeFacets = new List <RangeFacet>
                    {
                        new()
                        {
                            Ranges =
                            {
                                "Cost <= 200",
                                "Cost >= 300 and Cost <= 400",
                                "Cost >= 500 and Cost <= 600",
                                "Cost >= 700 and Cost <= 800",
                                "Cost >= 900"
                            }
                        },
                        new RangeFacet
                        {
                            Ranges =
                            {
                                "Megapixels <= 3",
                                "Megapixels >= 4 and Megapixels <= 7",
                                "Megapixels >= 8 and Megapixels <= 10",
                                "Megapixels >= 11",
                            }
                        }
                    };

                    commands.Put(
                        "facets/CameraFacets",
                        null,
                        new FacetSetup {
                        Id = "facets/CameraFacets", Facets = facets, RangeFacets = rangeFacets
                    },
                        null);
                }

                using (var session = store.OpenSession())
                {
                    var e = Assert.Throws <InvalidOperationException>(() =>
                                                                      session.Advanced.RawQuery <Camera>("from index 'CameraCost' select facet(id('facets/CameraFacets'))").ToList());
                    Assert.StartsWith("Raw query with aggregation by facet should be called by ExecuteAggregation or ExecuteAggregationAsync method.", e.Message);
                }

                using (var session = store.OpenAsyncSession())
                {
                    var e = await Assert.ThrowsAsync <InvalidOperationException>(async() =>
                                                                                 await session.Advanced.AsyncRawQuery <Camera>("from index 'CameraCost' select facet(id('facets/CameraFacets'))").ToListAsync());

                    Assert.StartsWith("Raw query with aggregation by facet should be called by ExecuteAggregation or ExecuteAggregationAsync method.", e.Message);
                }
            }
        }
    }
}
Example #5
0
        public async Task CanSendFacetedRawQueryAsync()
        {
            using (var store = GetDocumentStore())
            {
                var index = new CameraCost();
                await index.ExecuteAsync(store);

                using (var commands = store.Commands())
                {
                    for (var i = 0; i < 10; i++)
                    {
                        await commands.PutAsync(
                            "cameras/" + i,
                            null,
                            new Camera
                        {
                            Id           = "cameras/" + i,
                            Manufacturer = i % 2 == 0 ? "Manufacturer1" : "Manufacturer2",
                            Cost         = i * 100D,
                            Megapixels   = i * 1D
                        },
                            new Dictionary <string, object> {
                            { "@collection", "Cameras" }
                        });
                    }


                    WaitForIndexing(store);

                    var facets = new List <Facet>
                    {
                        new Facet
                        {
                            FieldName = "Manufacturer"
                        }
                    };

                    var rangeFacets = new List <RangeFacet>
                    {
                        new RangeFacet
                        {
                            Ranges =
                            {
                                "Cost <= 200",
                                "Cost >= 300 and Cost <= 400",
                                "Cost >= 500 and Cost <= 600",
                                "Cost >= 700 and Cost <= 800",
                                "Cost >= 900"
                            }
                        },
                        new()
                        {
                            Ranges =
                            {
                                "Megapixels <= 3",
                                "Megapixels >= 4 and Megapixels <= 7",
                                "Megapixels >= 8 and Megapixels <= 10",
                                "Megapixels >= 11",
                            }
                        }
                    };


                    await commands.PutAsync(
                        "facets/CameraFacets",
                        null,
                        new FacetSetup { Id = "facets/CameraFacets", Facets = facets, RangeFacets = rangeFacets },
                        null);

                    WaitForIndexing(store);

                    using (var session = store.OpenAsyncSession())
                    {
                        var facetResults = await session
                                           .Advanced
                                           .AsyncRawQuery <Camera>("from index 'CameraCost' select facet(id('facets/CameraFacets'))")
                                           .ExecuteAggregationAsync();

                        Assert.Equal(3, facetResults.Count);

                        Assert.Equal(2, facetResults["Manufacturer"].Values.Count);
                        Assert.Equal("manufacturer1", facetResults["Manufacturer"].Values[0].Range);
                        Assert.Equal(5, facetResults["Manufacturer"].Values[0].Count);
                        Assert.Equal("manufacturer2", facetResults["Manufacturer"].Values[1].Range);
                        Assert.Equal(5, facetResults["Manufacturer"].Values[1].Count);

                        Assert.Equal(5, facetResults["Cost"].Values.Count);
                        Assert.Equal("Cost <= 200", facetResults["Cost"].Values[0].Range);
                        Assert.Equal(3, facetResults["Cost"].Values[0].Count);
                        Assert.Equal("Cost >= 300 and Cost <= 400", facetResults["Cost"].Values[1].Range);
                        Assert.Equal(2, facetResults["Cost"].Values[1].Count);
                        Assert.Equal("Cost >= 500 and Cost <= 600", facetResults["Cost"].Values[2].Range);
                        Assert.Equal(2, facetResults["Cost"].Values[2].Count);
                        Assert.Equal("Cost >= 700 and Cost <= 800", facetResults["Cost"].Values[3].Range);
                        Assert.Equal(2, facetResults["Cost"].Values[3].Count);
                        Assert.Equal("Cost >= 900", facetResults["Cost"].Values[4].Range);
                        Assert.Equal(1, facetResults["Cost"].Values[4].Count);

                        Assert.Equal(4, facetResults["Megapixels"].Values.Count);
                        Assert.Equal("Megapixels <= 3", facetResults["Megapixels"].Values[0].Range);
                        Assert.Equal(4, facetResults["Megapixels"].Values[0].Count);
                        Assert.Equal("Megapixels >= 4 and Megapixels <= 7", facetResults["Megapixels"].Values[1].Range);
                        Assert.Equal(4, facetResults["Megapixels"].Values[1].Count);
                        Assert.Equal("Megapixels >= 8 and Megapixels <= 10", facetResults["Megapixels"].Values[2].Range);
                        Assert.Equal(2, facetResults["Megapixels"].Values[2].Count);
                        Assert.Equal("Megapixels >= 11", facetResults["Megapixels"].Values[3].Range);
                        Assert.Equal(0, facetResults["Megapixels"].Values[3].Count);
                    }

                    using (var session = store.OpenAsyncSession())
                    {
                        var r1 = await session
                                 .Advanced
                                 .AsyncRawQuery <Camera>("from index 'CameraCost' where Cost < 200 select facet(id('facets/CameraFacets'))")
                                 .ExecuteAggregationAsync();

                        var r2 = await session
                                 .Advanced
                                 .AsyncRawQuery <Camera>("from index 'CameraCost' where Megapixels < 3 select facet(id('facets/CameraFacets'))")
                                 .ExecuteAggregationAsync();

                        var multiFacetResults = new[] { r1, r2 };

                        Assert.Equal(3, multiFacetResults[0].Count);

                        Assert.Equal(2, multiFacetResults[0]["Manufacturer"].Values.Count);
                        Assert.Equal("manufacturer1", multiFacetResults[0]["Manufacturer"].Values[0].Range);
                        Assert.Equal(1, multiFacetResults[0]["Manufacturer"].Values[0].Count);
                        Assert.Equal("manufacturer2", multiFacetResults[0]["Manufacturer"].Values[1].Range);
                        Assert.Equal(1, multiFacetResults[0]["Manufacturer"].Values[1].Count);

                        Assert.Equal(5, multiFacetResults[0]["Cost"].Values.Count);
                        Assert.Equal("Cost <= 200", multiFacetResults[0]["Cost"].Values[0].Range);
                        Assert.Equal(2, multiFacetResults[0]["Cost"].Values[0].Count);
                        Assert.Equal("Cost >= 300 and Cost <= 400", multiFacetResults[0]["Cost"].Values[1].Range);
                        Assert.Equal(0, multiFacetResults[0]["Cost"].Values[1].Count);
                        Assert.Equal("Cost >= 500 and Cost <= 600", multiFacetResults[0]["Cost"].Values[2].Range);
                        Assert.Equal(0, multiFacetResults[0]["Cost"].Values[2].Count);
                        Assert.Equal("Cost >= 700 and Cost <= 800", multiFacetResults[0]["Cost"].Values[3].Range);
                        Assert.Equal(0, multiFacetResults[0]["Cost"].Values[3].Count);
                        Assert.Equal("Cost >= 900", multiFacetResults[0]["Cost"].Values[4].Range);
                        Assert.Equal(0, multiFacetResults[0]["Cost"].Values[4].Count);

                        Assert.Equal(4, multiFacetResults[0]["Megapixels"].Values.Count);
                        Assert.Equal("Megapixels <= 3", multiFacetResults[0]["Megapixels"].Values[0].Range);
                        Assert.Equal(2, multiFacetResults[0]["Megapixels"].Values[0].Count);
                        Assert.Equal("Megapixels >= 4 and Megapixels <= 7", multiFacetResults[0]["Megapixels"].Values[1].Range);
                        Assert.Equal(0, multiFacetResults[0]["Megapixels"].Values[1].Count);
                        Assert.Equal("Megapixels >= 8 and Megapixels <= 10", multiFacetResults[0]["Megapixels"].Values[2].Range);
                        Assert.Equal(0, multiFacetResults[0]["Megapixels"].Values[2].Count);
                        Assert.Equal("Megapixels >= 11", multiFacetResults[0]["Megapixels"].Values[3].Range);
                        Assert.Equal(0, multiFacetResults[0]["Megapixels"].Values[3].Count);


                        Assert.Equal(3, multiFacetResults[1].Count);

                        Assert.Equal(2, multiFacetResults[1]["Manufacturer"].Values.Count);
                        Assert.Equal("manufacturer1", multiFacetResults[1]["Manufacturer"].Values[0].Range);
                        Assert.Equal(2, multiFacetResults[1]["Manufacturer"].Values[0].Count);
                        Assert.Equal("manufacturer2", multiFacetResults[1]["Manufacturer"].Values[1].Range);
                        Assert.Equal(1, multiFacetResults[1]["Manufacturer"].Values[1].Count);

                        Assert.Equal(5, multiFacetResults[1]["Cost"].Values.Count);
                        Assert.Equal("Cost <= 200", multiFacetResults[1]["Cost"].Values[0].Range);
                        Assert.Equal(3, multiFacetResults[1]["Cost"].Values[0].Count);
                        Assert.Equal("Cost >= 300 and Cost <= 400", multiFacetResults[1]["Cost"].Values[1].Range);
                        Assert.Equal(0, multiFacetResults[1]["Cost"].Values[1].Count);
                        Assert.Equal("Cost >= 500 and Cost <= 600", multiFacetResults[1]["Cost"].Values[2].Range);
                        Assert.Equal(0, multiFacetResults[1]["Cost"].Values[2].Count);
                        Assert.Equal("Cost >= 700 and Cost <= 800", multiFacetResults[1]["Cost"].Values[3].Range);
                        Assert.Equal(0, multiFacetResults[1]["Cost"].Values[3].Count);
                        Assert.Equal("Cost >= 900", multiFacetResults[1]["Cost"].Values[4].Range);
                        Assert.Equal(0, multiFacetResults[1]["Cost"].Values[4].Count);

                        Assert.Equal(4, multiFacetResults[1]["Megapixels"].Values.Count);
                        Assert.Equal("Megapixels <= 3", multiFacetResults[1]["Megapixels"].Values[0].Range);
                        Assert.Equal(3, multiFacetResults[1]["Megapixels"].Values[0].Count);
                        Assert.Equal("Megapixels >= 4 and Megapixels <= 7", multiFacetResults[1]["Megapixels"].Values[1].Range);
                        Assert.Equal(0, multiFacetResults[1]["Megapixels"].Values[1].Count);
                        Assert.Equal("Megapixels >= 8 and Megapixels <= 10", multiFacetResults[1]["Megapixels"].Values[2].Range);
                        Assert.Equal(0, multiFacetResults[1]["Megapixels"].Values[2].Count);
                        Assert.Equal("Megapixels >= 11", multiFacetResults[1]["Megapixels"].Values[3].Range);
                        Assert.Equal(0, multiFacetResults[1]["Megapixels"].Values[3].Count);
                    }
                }
            }
        }
Example #6
0
        public void CanGetFacets()
        {
            using (var store = GetDocumentStore())
            {
                var index = new CameraCost();
                index.Execute(store);

                using (var commands = store.Commands())
                {
                    for (var i = 0; i < 10; i++)
                    {
                        commands.Put(
                            "cameras/" + i,
                            null,
                            new Camera
                        {
                            Id           = "cameras/" + i,
                            Manufacturer = i % 2 == 0 ? "Manufacturer1" : "Manufacturer2",
                            Cost         = i * 100D,
                            Megapixels   = i * 1D
                        },
                            new Dictionary <string, object> {
                            { "@collection", "Cameras" }
                        });
                    }


                    WaitForIndexing(store);

                    var facets = new List <Facet>
                    {
                        new Facet
                        {
                            Name = "Manufacturer"
                        },
                        new Facet
                        {
                            Name   = "Cost_D_Range",
                            Mode   = FacetMode.Ranges,
                            Ranges =
                            {
                                "[NULL TO 200.0]",
                                "[300.0 TO 400.0]",
                                "[500.0 TO 600.0]",
                                "[700.0 TO 800.0]",
                                "[900.0 TO NULL]"
                            }
                        },
                        new Facet
                        {
                            Name   = "Megapixels_D_Range",
                            Mode   = FacetMode.Ranges,
                            Ranges =
                            {
                                "[NULL TO 3.0]",
                                "[4.0 TO 7.0]",
                                "[8.0 TO 10.0]",
                                "[11.0 TO NULL]"
                            }
                        }
                    };

                    commands.Put(
                        "facets/CameraFacets",
                        null,
                        new FacetSetup {
                        Id = "facets/CameraFacets", Facets = facets
                    },
                        null);

                    WaitForIndexing(store);

                    using (var session = store.OpenSession())
                    {
                        var facetResults = session
                                           .Query <Camera, CameraCost>()
                                           .ToFacets("facets/CameraFacets");

                        Assert.Equal(3, facetResults.Results.Count);

                        Assert.Equal(2, facetResults.Results["Manufacturer"].Values.Count);
                        Assert.Equal("manufacturer1", facetResults.Results["Manufacturer"].Values[0].Range);
                        Assert.Equal(5, facetResults.Results["Manufacturer"].Values[0].Hits);
                        Assert.Equal("manufacturer2", facetResults.Results["Manufacturer"].Values[1].Range);
                        Assert.Equal(5, facetResults.Results["Manufacturer"].Values[1].Hits);

                        Assert.Equal(5, facetResults.Results["Cost_D_Range"].Values.Count);
                        Assert.Equal("[NULL TO 200.0]", facetResults.Results["Cost_D_Range"].Values[0].Range);
                        Assert.Equal(3, facetResults.Results["Cost_D_Range"].Values[0].Hits);
                        Assert.Equal("[300.0 TO 400.0]", facetResults.Results["Cost_D_Range"].Values[1].Range);
                        Assert.Equal(2, facetResults.Results["Cost_D_Range"].Values[1].Hits);
                        Assert.Equal("[500.0 TO 600.0]", facetResults.Results["Cost_D_Range"].Values[2].Range);
                        Assert.Equal(2, facetResults.Results["Cost_D_Range"].Values[2].Hits);
                        Assert.Equal("[700.0 TO 800.0]", facetResults.Results["Cost_D_Range"].Values[3].Range);
                        Assert.Equal(2, facetResults.Results["Cost_D_Range"].Values[3].Hits);
                        Assert.Equal("[900.0 TO NULL]", facetResults.Results["Cost_D_Range"].Values[4].Range);
                        Assert.Equal(1, facetResults.Results["Cost_D_Range"].Values[4].Hits);

                        Assert.Equal(4, facetResults.Results["Megapixels_D_Range"].Values.Count);
                        Assert.Equal("[NULL TO 3.0]", facetResults.Results["Megapixels_D_Range"].Values[0].Range);
                        Assert.Equal(4, facetResults.Results["Megapixels_D_Range"].Values[0].Hits);
                        Assert.Equal("[4.0 TO 7.0]", facetResults.Results["Megapixels_D_Range"].Values[1].Range);
                        Assert.Equal(4, facetResults.Results["Megapixels_D_Range"].Values[1].Hits);
                        Assert.Equal("[8.0 TO 10.0]", facetResults.Results["Megapixels_D_Range"].Values[2].Range);
                        Assert.Equal(2, facetResults.Results["Megapixels_D_Range"].Values[2].Hits);
                        Assert.Equal("[11.0 TO NULL]", facetResults.Results["Megapixels_D_Range"].Values[3].Range);
                        Assert.Equal(0, facetResults.Results["Megapixels_D_Range"].Values[3].Hits);
                    }

                    using (var session = store.OpenSession())
                    {
                        var multiFacetResults = session.Advanced.DocumentStore.Operations.Send(new GetMultiFacetsOperation(new FacetQuery()
                        {
                            Query         = $"FROM INDEX '{index.IndexName}' WHERE Cost < 200",
                            FacetSetupDoc = "facets/CameraFacets"
                        }, new FacetQuery
                        {
                            Query         = $"FROM INDEX '{index.IndexName}' WHERE Megapixels < 3",
                            FacetSetupDoc = "facets/CameraFacets"
                        }));

                        Assert.Equal(3, multiFacetResults[0].Results.Count);

                        Assert.Equal(2, multiFacetResults[0].Results["Manufacturer"].Values.Count);
                        Assert.Equal("manufacturer1", multiFacetResults[0].Results["Manufacturer"].Values[0].Range);
                        Assert.Equal(1, multiFacetResults[0].Results["Manufacturer"].Values[0].Hits);
                        Assert.Equal("manufacturer2", multiFacetResults[0].Results["Manufacturer"].Values[1].Range);
                        Assert.Equal(1, multiFacetResults[0].Results["Manufacturer"].Values[1].Hits);

                        Assert.Equal(5, multiFacetResults[0].Results["Cost_D_Range"].Values.Count);
                        Assert.Equal("[NULL TO 200.0]", multiFacetResults[0].Results["Cost_D_Range"].Values[0].Range);
                        Assert.Equal(2, multiFacetResults[0].Results["Cost_D_Range"].Values[0].Hits);
                        Assert.Equal("[300.0 TO 400.0]", multiFacetResults[0].Results["Cost_D_Range"].Values[1].Range);
                        Assert.Equal(0, multiFacetResults[0].Results["Cost_D_Range"].Values[1].Hits);
                        Assert.Equal("[500.0 TO 600.0]", multiFacetResults[0].Results["Cost_D_Range"].Values[2].Range);
                        Assert.Equal(0, multiFacetResults[0].Results["Cost_D_Range"].Values[2].Hits);
                        Assert.Equal("[700.0 TO 800.0]", multiFacetResults[0].Results["Cost_D_Range"].Values[3].Range);
                        Assert.Equal(0, multiFacetResults[0].Results["Cost_D_Range"].Values[3].Hits);
                        Assert.Equal("[900.0 TO NULL]", multiFacetResults[0].Results["Cost_D_Range"].Values[4].Range);
                        Assert.Equal(0, multiFacetResults[0].Results["Cost_D_Range"].Values[4].Hits);

                        Assert.Equal(4, multiFacetResults[0].Results["Megapixels_D_Range"].Values.Count);
                        Assert.Equal("[NULL TO 3.0]", multiFacetResults[0].Results["Megapixels_D_Range"].Values[0].Range);
                        Assert.Equal(2, multiFacetResults[0].Results["Megapixels_D_Range"].Values[0].Hits);
                        Assert.Equal("[4.0 TO 7.0]", multiFacetResults[0].Results["Megapixels_D_Range"].Values[1].Range);
                        Assert.Equal(0, multiFacetResults[0].Results["Megapixels_D_Range"].Values[1].Hits);
                        Assert.Equal("[8.0 TO 10.0]", multiFacetResults[0].Results["Megapixels_D_Range"].Values[2].Range);
                        Assert.Equal(0, multiFacetResults[0].Results["Megapixels_D_Range"].Values[2].Hits);
                        Assert.Equal("[11.0 TO NULL]", multiFacetResults[0].Results["Megapixels_D_Range"].Values[3].Range);
                        Assert.Equal(0, multiFacetResults[0].Results["Megapixels_D_Range"].Values[3].Hits);


                        Assert.Equal(3, multiFacetResults[1].Results.Count);

                        Assert.Equal(2, multiFacetResults[1].Results["Manufacturer"].Values.Count);
                        Assert.Equal("manufacturer1", multiFacetResults[1].Results["Manufacturer"].Values[0].Range);
                        Assert.Equal(2, multiFacetResults[1].Results["Manufacturer"].Values[0].Hits);
                        Assert.Equal("manufacturer2", multiFacetResults[1].Results["Manufacturer"].Values[1].Range);
                        Assert.Equal(1, multiFacetResults[1].Results["Manufacturer"].Values[1].Hits);

                        Assert.Equal(5, multiFacetResults[1].Results["Cost_D_Range"].Values.Count);
                        Assert.Equal("[NULL TO 200.0]", multiFacetResults[1].Results["Cost_D_Range"].Values[0].Range);
                        Assert.Equal(3, multiFacetResults[1].Results["Cost_D_Range"].Values[0].Hits);
                        Assert.Equal("[300.0 TO 400.0]", multiFacetResults[1].Results["Cost_D_Range"].Values[1].Range);
                        Assert.Equal(0, multiFacetResults[1].Results["Cost_D_Range"].Values[1].Hits);
                        Assert.Equal("[500.0 TO 600.0]", multiFacetResults[1].Results["Cost_D_Range"].Values[2].Range);
                        Assert.Equal(0, multiFacetResults[1].Results["Cost_D_Range"].Values[2].Hits);
                        Assert.Equal("[700.0 TO 800.0]", multiFacetResults[1].Results["Cost_D_Range"].Values[3].Range);
                        Assert.Equal(0, multiFacetResults[1].Results["Cost_D_Range"].Values[3].Hits);
                        Assert.Equal("[900.0 TO NULL]", multiFacetResults[1].Results["Cost_D_Range"].Values[4].Range);
                        Assert.Equal(0, multiFacetResults[1].Results["Cost_D_Range"].Values[4].Hits);

                        Assert.Equal(4, multiFacetResults[1].Results["Megapixels_D_Range"].Values.Count);
                        Assert.Equal("[NULL TO 3.0]", multiFacetResults[1].Results["Megapixels_D_Range"].Values[0].Range);
                        Assert.Equal(3, multiFacetResults[1].Results["Megapixels_D_Range"].Values[0].Hits);
                        Assert.Equal("[4.0 TO 7.0]", multiFacetResults[1].Results["Megapixels_D_Range"].Values[1].Range);
                        Assert.Equal(0, multiFacetResults[1].Results["Megapixels_D_Range"].Values[1].Hits);
                        Assert.Equal("[8.0 TO 10.0]", multiFacetResults[1].Results["Megapixels_D_Range"].Values[2].Range);
                        Assert.Equal(0, multiFacetResults[1].Results["Megapixels_D_Range"].Values[2].Hits);
                        Assert.Equal("[11.0 TO NULL]", multiFacetResults[1].Results["Megapixels_D_Range"].Values[3].Range);
                        Assert.Equal(0, multiFacetResults[1].Results["Megapixels_D_Range"].Values[3].Hits);
                    }
                }
            }
        }