示例#1
0
        public void ParseResultsWithFacetPivot()
        {
            var parser = new FacetsResponseParser <Product>();
            var xml    = EmbeddedResource.GetEmbeddedXml(GetType(), "Resources.responseWithFacetPivoting.xml");
            var r      = new SolrQueryResults <Product>();

            parser.Parse(xml, r);
            Assert.IsNotNull(r.FacetPivots);
            //Console.WriteLine(r.FacetPivots.Count);
            Assert.IsTrue(r.FacetPivots.ContainsKey("inStock,manu"));

            Assert.AreEqual(2, r.FacetPivots["inStock,manu"].Count);
            Assert.AreEqual("inStock", r.FacetPivots["inStock,manu"][0].Field);
            Assert.AreEqual(10, r.FacetPivots["inStock,manu"][0].ChildPivots.Count);
        }
示例#2
0
        public void ParseFacetResults()
        {
            var parser = new FacetsResponseParser <TestDocumentWithArrays>();
            var xml    = EmbeddedResource.GetEmbeddedXml(GetType(), "Resources.responseWithFacet.xml");
            var r      = new SolrQueryResults <TestDocumentWithArrays>();

            parser.Parse(xml, r);
            Assert.IsNotNull(r.FacetFields);
            Assert.IsTrue(r.FacetFields.ContainsKey("cat"));
            Assert.IsTrue(r.FacetFields.ContainsKey("inStock"));
            Assert.AreEqual(2, r.FacetFields["cat"].First(q => q.Key == "connector").Value);
            Assert.AreEqual(2, r.FacetFields["cat"].First(q => q.Key == "").Value); // facet.missing as empty string

            Assert.IsNotNull(r.FacetQueries);
            Assert.AreEqual(1, r.FacetQueries.Count);
        }
示例#3
0
        public void ParseFacetResults()
        {
            var parser = new FacetsResponseParser <TestDocumentWithArrays>();
            var xml    = EmbeddedResource.GetEmbeddedXml(GetType(), "Resources.responseWithFacet.xml");
            var r      = new SolrQueryResults <TestDocumentWithArrays>();

            parser.Parse(xml, r);
            Assert.NotNull(r.FacetFields);
            //Console.WriteLine(r.FacetFields.Count);
            Assert.True(r.FacetFields.ContainsKey("cat"));
            Assert.True(r.FacetFields.ContainsKey("inStock"));
            Assert.Equal(2, r.FacetFields["cat"].First(q => q.Key == "connector").Value);
            Assert.Equal(2, r.FacetFields["cat"].First(q => q.Key == "").Value); // facet.missing as empty string


            //Facet Ranges
            Assert.NotNull(r.FacetRanges);
            Assert.Equal(2, r.FacetRanges.Count);
            Assert.Equal("date-timestamp", r.FacetRanges.First().Key);
            Assert.Equal("2017-07-30T00:00:00Z", r.FacetRanges.First().Value.Start);
            Assert.Equal("2017-08-30T00:00:00Z", r.FacetRanges.First().Value.End);
            Assert.Equal("+1DAY", r.FacetRanges.First().Value.Gap);
            Assert.Equal(41622120, r.FacetRanges.First().Value.OtherResults[FacetRangeOther.Before]);
            Assert.Equal(47336, r.FacetRanges.First().Value.OtherResults[FacetRangeOther.After]);
            Assert.Equal(75812, r.FacetRanges.First().Value.OtherResults[FacetRangeOther.Between]);
            Assert.Equal(31, r.FacetRanges.First().Value.RangeResults.Count);
            Assert.Equal("2017-07-30T00:00:00Z", r.FacetRanges.First().Value.RangeResults.First().Key);
            Assert.Equal(222, r.FacetRanges.First().Value.RangeResults.First().Value);
            Assert.Equal("2017-08-29T00:00:00Z", r.FacetRanges.First().Value.RangeResults.Last().Key);
            Assert.Equal(20, r.FacetRanges.First().Value.RangeResults.Last().Value);

            Assert.Equal("version", r.FacetRanges.Last().Key);
            Assert.Equal("1000", r.FacetRanges.Last().Value.Gap);
            Assert.Equal("1531035549990449850", r.FacetRanges.Last().Value.RangeResults.First().Key);
            Assert.Equal(20, r.FacetRanges.Last().Value.RangeResults.First().Value);
            Assert.Equal("1531035549990659850", r.FacetRanges.Last().Value.RangeResults.Last().Key);
            Assert.Equal(0, r.FacetRanges.Last().Value.RangeResults.Last().Value);


            //Facet Intervals
            Assert.NotNull(r.FacetIntervals);
            Assert.Equal(2, r.FacetIntervals.Count);
            Assert.Equal("letters", r.FacetIntervals.First().Key);
            Assert.Equal(3, r.FacetIntervals.First().Value.Count);
            Assert.Equal("[*,b]", r.FacetIntervals.First().Value.First().Key);
            Assert.Equal(5, r.FacetIntervals.First().Value.First().Value);
            Assert.Equal("bar", r.FacetIntervals.First().Value.Last().Key);
            Assert.Equal(4544341, r.FacetIntervals.First().Value.Last().Value);


            Assert.Equal("number", r.FacetIntervals.Last().Key);
            Assert.Equal(2, r.FacetIntervals.Last().Value.Count);
            Assert.Equal("[0,500]", r.FacetIntervals.Last().Value.First().Key);
            Assert.Equal(9, r.FacetIntervals.Last().Value.First().Value);
            Assert.Equal("[500,1000]", r.FacetIntervals.Last().Value.Last().Key);
            Assert.Equal(123, r.FacetIntervals.Last().Value.Last().Value);



            //Facet Queries
            Assert.NotNull(r.FacetQueries);
            //Console.WriteLine(r.FacetQueries.Count);
            Assert.Equal(1, r.FacetQueries.Count);
        }