public void BuildAMultipleSelectFacetViewModelWithMultipleConstraintsApplied() { var results = SolrNetFacetTestFramework.RunSolrGetResults( "<?xml version=\"1.0\" encoding=\"UTF-8\"?><response><lst name=\"responseHeader\"><int name=\"status\">0</int><int name=\"QTime\">2</int><lst name=\"params\"><str name=\"facet\">true</str><str name=\"q\">*:*</str><str name=\"facet.field\">{!key=brands ex=brandsfilter}brand_f</str><str name=\"fq\">{!tag=brandsfilter}brand_f:(iPhone OR LCD televisions OR LED televisions OR Smartphones)</str><str name=\"version\">2.2</str><str name=\"rows\">100000000</str></lst></lst><result name=\"response\" numFound=\"7\" start=\"0\"><doc><str name=\"id\">65538</str><str name=\"categoryid\">32770</str><float name=\"unitprice\">523.0</float><str name=\"unitprice_c\">523.0000,USD</str><str name=\"name\">Galaxy Note</str><str name=\"url\">home/electronics/phones/galaxy-note</str><long name=\"_version_\">1435991846240124928</long></doc><doc><str name=\"id\">65536</str><str name=\"categoryid\">32770</str><float name=\"unitprice\">100.0</float><str name=\"unitprice_c\">100.0000,USD</str><str name=\"name\">iPhone</str><str name=\"url\">home/electronics/phones/iphone</str><long name=\"_version_\">1435991846256902144</long></doc><doc><str name=\"id\">65537</str><str name=\"categoryid\">32770</str><float name=\"unitprice\">200.0</float><str name=\"unitprice_c\">200.0000,USD</str><str name=\"name\">iPhone3G</str><str name=\"url\">home/electronics/phones/iphone3g</str><long name=\"_version_\">1435991846263193600</long></doc><doc><str name=\"id\">65540</str><str name=\"categoryid\">32770</str><float name=\"unitprice\">250.0</float><str name=\"unitprice_c\">250.0000,USD</str><str name=\"name\">iPhone3GS</str><str name=\"url\">home/electronics/phones/iphone3gs</str><long name=\"_version_\">1435991846267387904</long></doc><doc><str name=\"id\">65541</str><str name=\"categoryid\">32770</str><float name=\"unitprice\">350.0</float><str name=\"unitprice_c\">350.0000,USD</str><str name=\"name\">iPhone4</str><str name=\"url\">home/electronics/phones/iphone4</str><long name=\"_version_\">1435991846272630784</long></doc><doc><str name=\"id\">65539</str><str name=\"categoryid\">32770</str><float name=\"unitprice\">550.0</float><str name=\"unitprice_c\">550.0000,USD</str><str name=\"name\">iPhone4S</str><str name=\"url\">home/electronics/phones/iphone4s</str><long name=\"_version_\">1435991846277873664</long></doc><doc><str name=\"id\">65548</str><str name=\"categoryid\">32770</str><float name=\"unitprice\">270.0</float><str name=\"unitprice_c\">270.0000,USD</str><str name=\"name\">Omina W</str><str name=\"url\">home/electronics/phones/omina-w</str><long name=\"_version_\">1435991846282067968</long></doc></result><lst name=\"facet_counts\"><lst name=\"facet_queries\"/><lst name=\"facet_fields\"><lst name=\"brands\"><int name=\"iPhone\">5</int><int name=\"iPad\">3</int><int name=\"Mobile phones\">2</int><int name=\"Smartphones\">2</int><int name=\"LCD televisions\">1</int><int name=\"LED televisions\">1</int><int name=\"Plasma televisions\">1</int></lst></lst><lst name=\"facet_dates\"/><lst name=\"facet_ranges\"/></lst></response>", @"http://localhost:8983/solr/select?q=*:*&rows=100000000&fq={!tag=brandsfilter}brand_f:(iPhone+OR+LCD+televisions+OR+LED+televisions+OR+Smartphones)&facet=true&facet.field={!key=brands+ex=brandsfilter}brand_f&version=2.2"); var brandFacet = new BrandFacet(new NameValueCollection { {"fb", "Smartphones"}, {"fb", "iPhone"}, {"fb", "LCD televisions"}, {"fb", "LED televisions"} }); var facetViewModel = brandFacet.BuildViewModel(results); var expectedValues = new[] { new { IsApplied = false, IsDisabled = false, Count = 3, Name = "iPad", Url = "/?fb=iPad&fb=iPhone&fb=LCD+televisions&fb=LED+televisions&fb=Smartphones" }, new { IsApplied = true, IsDisabled = false, Count = 5, Name = "iPhone", Url = "/?fb=LCD+televisions&fb=LED+televisions&fb=Smartphones" }, new { IsApplied = true, IsDisabled = false, Count = 1, Name = "LCD televisions", Url = "/?fb=iPhone&fb=LED+televisions&fb=Smartphones" }, new { IsApplied = true, IsDisabled = false, Count = 1, Name = "LED televisions", Url = "/?fb=iPhone&fb=LCD+televisions&fb=Smartphones" }, new { IsApplied = false, IsDisabled = false, Count = 2, Name = "Mobile phones", Url = "/?fb=iPhone&fb=LCD+televisions&fb=LED+televisions&fb=Mobile+phones&fb=Smartphones" }, new { IsApplied = false, IsDisabled = false, Count = 1, Name = "Plasma televisions", Url = "/?fb=iPhone&fb=LCD+televisions&fb=LED+televisions&fb=Plasma+televisions&fb=Smartphones" }, new { IsApplied = true, IsDisabled = false, Count = 2, Name = "Smartphones", Url = "/?fb=iPhone&fb=LCD+televisions&fb=LED+televisions" } }; Assert.AreEqual(7, facetViewModel.Constraints.Length); for (var index = 0; index < facetViewModel.Constraints.Length; index++) { Assert.AreEqual(expectedValues[index].IsApplied, facetViewModel.Constraints[index].IsApplied); Assert.AreEqual(expectedValues[index].IsDisabled, facetViewModel.Constraints[index].IsDisabled); Assert.AreEqual(expectedValues[index].Count, facetViewModel.Constraints[index].Count); Assert.AreEqual(expectedValues[index].Name, facetViewModel.Constraints[index].Name); Assert.AreEqual(expectedValues[index].Url, facetViewModel.Constraints[index].Url); } }
public void CreateTwoFacetsWithOneBeingARangeFacetThatBothHaveMultipleConstraintsApplied() { SolrNetFacetTestFramework.RunSolrUrlCreationTest(@"http://localhost:8983/solr/select?q=*:*&rows=100000000&fq={!tag=unitpricefilter}unitprice:([*+TO+99.99]+OR+[100+TO+499.99])&fq={!tag=brandsfilter}brand_f:(iPhone+OR+LCD+televisions+OR+LED+televisions+OR+Smartphones)&facet=true&facet.query={!label=*-99.99\+ex=unitpricefilter}unitprice:[*+TO+99.99]&facet.query={!label=100-499.99\+ex=unitpricefilter}unitprice:[100+TO+499.99]&facet.query={!label=*-99.99-ruledout\+ex=brandsfilter,unitpricefilter}unitprice:[*+TO+99.99]&facet.query={!label=100-499.99-ruledout\+ex=brandsfilter,unitpricefilter}unitprice:[100+TO+499.99]&facet.field={!key=brands+ex=brandsfilter}brand_f&facet.field={!key=brandsruledout+ex=unitpricefilter,brandsfilter}brand_f&version=2.2", solr => { var querystring = new NameValueCollection { {"fps", "*"}, {"fpl", "99.99"}, {"fps", "100"}, {"fpl", "499.99"}, {"fb", "Smartphones"}, {"fb", "iPhone"}, {"fb", "LCD televisions"}, {"fb", "LED televisions"} }; var queryOptions = new QueryOptions(); var brandFacet = new BrandFacet(querystring); var priceFacet = new PriceFacet(querystring, false, new RangeQuery("*", "99.99"), new RangeQuery("100", "499.99")); var facets = new IFacet[] { priceFacet, brandFacet }; priceFacet.BuildDependencies(facets); brandFacet.BuildDependencies(facets); priceFacet.BuildQuery(queryOptions); brandFacet.BuildQuery(queryOptions); return solr.Query(SolrQuery.All, queryOptions); }); }
public void BuildFacetViewModelsForTwoFacetsWithOneBeingARangeFacetThatBothHaveMultipleConstraintsApplied() { var results = SolrNetFacetTestFramework.RunSolrGetResults( "<?xml version=\"1.0\" encoding=\"UTF-8\"?><response><lst name=\"responseHeader\"><int name=\"status\">0</int><int name=\"QTime\">25</int><lst name=\"params\"><str name=\"facet\">true</str><arr name=\"facet.query\"><str>{!label=*-99.99 ex=unitpricefilter}unitprice:[* TO 99.99]</str><str>{!label=100-499.99 ex=unitpricefilter}unitprice:[100 TO 499.99]</str><str>{!label=*-99.99-ruledout ex=brandsfilter,unitpricefilter}unitprice:[* TO 99.99]</str><str>{!label=100-499.99-ruledout ex=brandsfilter,unitpricefilter}unitprice:[100 TO 499.99]</str></arr><str name=\"q\">*:*</str><arr name=\"facet.field\"><str>{!key=brands ex=brandsfilter}brand_f</str><str>{!key=brandsruledout ex=unitpricefilter,brandsfilter}brand_f</str></arr><arr name=\"fq\"><str>{!tag=unitpricefilter}unitprice:([* TO 99.99] OR [100 TO 499.99])</str><str>{!tag=brandsfilter}brand_f:(iPhone OR LCD televisions OR LED televisions OR Smartphones)</str></arr><str name=\"version\">2.2</str><str name=\"rows\">100000000</str></lst></lst><result name=\"response\" numFound=\"5\" start=\"0\"><doc><str name=\"id\">65536</str><str name=\"categoryid\">32770</str><float name=\"unitprice\">100.0</float><str name=\"unitprice_c\">100.0000,USD</str><str name=\"name\">iPhone</str><str name=\"url\">home/electronics/phones/iphone</str><long name=\"_version_\">1435991846256902144</long></doc><doc><str name=\"id\">65537</str><str name=\"categoryid\">32770</str><float name=\"unitprice\">200.0</float><str name=\"unitprice_c\">200.0000,USD</str><str name=\"name\">iPhone3G</str><str name=\"url\">home/electronics/phones/iphone3g</str><long name=\"_version_\">1435991846263193600</long></doc><doc><str name=\"id\">65540</str><str name=\"categoryid\">32770</str><float name=\"unitprice\">250.0</float><str name=\"unitprice_c\">250.0000,USD</str><str name=\"name\">iPhone3GS</str><str name=\"url\">home/electronics/phones/iphone3gs</str><long name=\"_version_\">1435991846267387904</long></doc><doc><str name=\"id\">65541</str><str name=\"categoryid\">32770</str><float name=\"unitprice\">350.0</float><str name=\"unitprice_c\">350.0000,USD</str><str name=\"name\">iPhone4</str><str name=\"url\">home/electronics/phones/iphone4</str><long name=\"_version_\">1435991846272630784</long></doc><doc><str name=\"id\">65548</str><str name=\"categoryid\">32770</str><float name=\"unitprice\">270.0</float><str name=\"unitprice_c\">270.0000,USD</str><str name=\"name\">Omina W</str><str name=\"url\">home/electronics/phones/omina-w</str><long name=\"_version_\">1435991846282067968</long></doc></result><lst name=\"facet_counts\"><lst name=\"facet_queries\"><int name=\"{!label=*-99.99 ex=unitpricefilter}unitprice:[* TO 99.99]\">0</int><int name=\"{!label=100-499.99 ex=unitpricefilter}unitprice:[100 TO 499.99]\">5</int><int name=\"{!label=*-99.99-ruledout ex=brandsfilter,unitpricefilter}unitprice:[* TO 99.99]\">1</int><int name=\"{!label=100-499.99-ruledout ex=brandsfilter,unitpricefilter}unitprice:[100 TO 499.99]\">8</int></lst><lst name=\"facet_fields\"><lst name=\"brands\"><int name=\"iPhone\">4</int><int name=\"Mobile phones\">2</int><int name=\"iPad\">2</int><int name=\"Smartphones\">1</int><int name=\"LCD televisions\">0</int><int name=\"LED televisions\">0</int><int name=\"Plasma televisions\">0</int></lst><lst name=\"brandsruledout\"><int name=\"iPhone\">5</int><int name=\"iPad\">3</int><int name=\"Mobile phones\">2</int><int name=\"Smartphones\">2</int><int name=\"LCD televisions\">1</int><int name=\"LED televisions\">1</int><int name=\"Plasma televisions\">1</int></lst></lst><lst name=\"facet_dates\"/><lst name=\"facet_ranges\"/></lst></response>", @"http://localhost:8983/solr/select?q=*:*&rows=100000000&fq={!tag=unitpricefilter}unitprice:([* TO 99.99] OR [100 TO 499.99])&fq={!tag=brandsfilter}brand_f:(iPhone OR LCD televisions OR LED televisions OR Smartphones)&facet=true&facet.query={!label=*-99.99 ex=unitpricefilter}unitprice:[* TO 99.99]&facet.query={!label=100-499.99 ex=unitpricefilter}unitprice:[100 TO 499.99]&facet.query={!label=*-99.99-ruledout ex=brandsfilter,unitpricefilter}unitprice:[* TO 99.99]&facet.query={!label=100-499.99-ruledout ex=brandsfilter,unitpricefilter}unitprice:[100 TO 499.99]&facet.field={!key=brands ex=brandsfilter}brand_f&facet.field={!key=brandsruledout ex=unitpricefilter,brandsfilter}brand_f&version=2.2"); var querystring = new NameValueCollection { {"fps", "*"}, {"fpl", "99.99"}, {"fps", "100"}, {"fpl", "499.99"}, {"fb", "Smartphones"}, {"fb", "iPhone"}, {"fb", "LCD televisions"}, {"fb", "LED televisions"} }; var brandFacet = new BrandFacet(querystring); var priceFacet = new PriceFacet(querystring, false, new RangeQuery("*", "99.99"), new RangeQuery("100", "499.99")); var facets = new IFacet[] { brandFacet, priceFacet }; brandFacet.BuildDependencies(facets); priceFacet.BuildDependencies(facets); var brandFacetViewModel = brandFacet.BuildViewModel(results); var priceFacetViewModel = priceFacet.BuildViewModel(results); var expectedBrandValues = new[] { new { IsApplied = false, IsDisabled = false, Count = 2, Name = "iPad", Url = "/?fps=*&fps=100&fpl=99.99&fpl=499.99&fb=iPad&fb=iPhone&fb=LCD+televisions&fb=LED+televisions&fb=Smartphones" }, new { IsApplied = true, IsDisabled = false, Count = 4, Name = "iPhone", Url = "/?fps=*&fps=100&fpl=99.99&fpl=499.99&fb=LCD+televisions&fb=LED+televisions&fb=Smartphones" }, new { IsApplied = true, IsDisabled = true, Count = 1, Name = "LCD televisions", Url = string.Empty }, new { IsApplied = true, IsDisabled = true, Count = 1, Name = "LED televisions", Url = string.Empty }, new { IsApplied = false, IsDisabled = false, Count = 2, Name = "Mobile phones", Url = "/?fps=*&fps=100&fpl=99.99&fpl=499.99&fb=iPhone&fb=LCD+televisions&fb=LED+televisions&fb=Mobile+phones&fb=Smartphones" }, new { IsApplied = false, IsDisabled = true, Count = 1, Name = "Plasma televisions", Url = string.Empty }, new { IsApplied = true, IsDisabled = false, Count = 1, Name = "Smartphones", Url = "/?fps=*&fps=100&fpl=99.99&fpl=499.99&fb=iPhone&fb=LCD+televisions&fb=LED+televisions" } }; Assert.AreEqual(7, brandFacetViewModel.Constraints.Length); for (var index = 0; index < brandFacetViewModel.Constraints.Length; index++) { Assert.AreEqual(expectedBrandValues[index].IsApplied, brandFacetViewModel.Constraints[index].IsApplied); Assert.AreEqual(expectedBrandValues[index].IsDisabled, brandFacetViewModel.Constraints[index].IsDisabled); Assert.AreEqual(expectedBrandValues[index].Count, brandFacetViewModel.Constraints[index].Count); Assert.AreEqual(expectedBrandValues[index].Name, brandFacetViewModel.Constraints[index].Name); Assert.AreEqual(expectedBrandValues[index].Url, brandFacetViewModel.Constraints[index].Url); } var expectedPriceValues = new[] { new { IsApplied = true, IsDisabled = true, Count = 1, Name = string.Format("Up to {0}99.99", NumberFormatInfo.CurrentInfo.CurrencySymbol), Url = string.Empty }, new { IsApplied = true, IsDisabled = false, Count = 5, Name = string.Format("{0}100.00 - {0}499.99", NumberFormatInfo.CurrentInfo.CurrencySymbol), Url = "/?fb=iPhone&fb=LCD+televisions&fb=LED+televisions&fb=Smartphones&fps=*&fpl=99.99" } }; Assert.AreEqual(2, priceFacetViewModel.Constraints.Length); for (var index = 0; index < priceFacetViewModel.Constraints.Length; index++) { Assert.AreEqual(expectedPriceValues[index].IsApplied, priceFacetViewModel.Constraints[index].IsApplied); Assert.AreEqual(expectedPriceValues[index].IsDisabled, priceFacetViewModel.Constraints[index].IsDisabled); Assert.AreEqual(expectedPriceValues[index].Count, priceFacetViewModel.Constraints[index].Count); Assert.AreEqual(expectedPriceValues[index].Name, priceFacetViewModel.Constraints[index].Name); Assert.AreEqual(expectedPriceValues[index].Url, priceFacetViewModel.Constraints[index].Url); } }
public void CreateThreeFacetsThatAllHaveOneConstraintApplied() { SolrNetFacetTestFramework.RunSolrUrlCreationTest(@"http://localhost:8983/solr/select?q=*:*&rows=100000000&fq={!tag=brandsfilter}brand_f:(Smartphones)&fq={!tag=manufacturersfilter}manufacturer_f:(Samsung)&fq={!tag=unitpricefilter}unitprice:([500+TO+600])&facet=true&facet.field={!key=brands+ex=brandsfilter}brand_f&facet.field={!key=brandsruledout+ex=manufacturersfilter,unitpricefilter,brandsfilter}brand_f&facet.field={!key=manufacturers+ex=manufacturersfilter}manufacturer_f&facet.field={!key=manufacturersruledout+ex=brandsfilter,unitpricefilter,manufacturersfilter}manufacturer_f&facet.query={!label=500-600\+ex=unitpricefilter}unitprice:[500+TO+600]&facet.query={!label=601-1000\+ex=unitpricefilter}unitprice:[601+TO+1000]&facet.query={!label=500-600-ruledout\+ex=brandsfilter,manufacturersfilter,unitpricefilter}unitprice:[500+TO+600]&facet.query={!label=601-1000-ruledout\+ex=brandsfilter,manufacturersfilter,unitpricefilter}unitprice:[601+TO+1000]&version=2.2", solr => { var querystring = new NameValueCollection { {"fb", "Smartphones"}, {"fm", "Samsung"}, {"fps", "500"}, {"fpl", "600"} }; var queryOptions = new QueryOptions(); var brandFacet = new BrandFacet(querystring); var manufacturerFacet = new ManufacturerFacet(querystring); var priceFacet = new PriceFacet(querystring, false, new RangeQuery("500", "600"), new RangeQuery("601", "1000")); var facets = new IFacet[] { brandFacet, manufacturerFacet, priceFacet }; brandFacet.BuildDependencies(facets); manufacturerFacet.BuildDependencies(facets); priceFacet.BuildDependencies(facets); brandFacet.BuildQuery(queryOptions); manufacturerFacet.BuildQuery(queryOptions); priceFacet.BuildQuery(queryOptions); return solr.Query(SolrQuery.All, queryOptions); }); }
public void CreateTwoFacetsThatBothHaveMultipleConstraintsApplied() { SolrNetFacetTestFramework.RunSolrUrlCreationTest(@"http://localhost:8983/solr/select?q=*:*&rows=100000000&fq={!tag=brandsfilter}brand_f:(iPhone+OR+LCD+televisions+OR+LED+televisions+OR+Smartphones)&fq={!tag=manufacturersfilter}manufacturer_f:(Apple+OR+Samsung)&facet=true&facet.field={!key=brands+ex=brandsfilter}brand_f&facet.field={!key=brandsruledout+ex=manufacturersfilter,brandsfilter}brand_f&facet.field={!key=manufacturers+ex=manufacturersfilter}manufacturer_f&facet.field={!key=manufacturersruledout+ex=brandsfilter,manufacturersfilter}manufacturer_f&version=2.2", solr => { var querystring = new NameValueCollection { {"fb", "Smartphones"}, {"fb", "iPhone"}, {"fb", "LCD televisions"}, {"fb", "LED televisions"}, {"fm", "Apple"}, {"fm", "Samsung"} }; var queryOptions = new QueryOptions(); var brandFacet = new BrandFacet(querystring); var manufacturerFacet = new ManufacturerFacet(querystring); var facets = new IFacet[] { brandFacet, manufacturerFacet }; brandFacet.BuildDependencies(facets); manufacturerFacet.BuildDependencies(facets); brandFacet.BuildQuery(queryOptions); manufacturerFacet.BuildQuery(queryOptions); return solr.Query(SolrQuery.All, queryOptions); }); }
public void CreateAFacetWithOneConstraintApplied() { SolrNetFacetTestFramework.RunSolrUrlCreationTest(@"http://localhost:8983/solr/select?q=*:*&rows=100000000&fq={!tag=brandsfilter}brand_f:(Smartphones)&facet=true&facet.field={!key=brands+ex=brandsfilter}brand_f&version=2.2", solr => { var queryOptions = new QueryOptions(); var facet = new BrandFacet(new NameValueCollection { {"fb", "Smartphones"} }); facet.BuildQuery(queryOptions); return solr.Query(SolrQuery.All, queryOptions); }); }
public void CreateASingleSelectionFacetThatWillOnlyApplyTheFirstConstraintWhenMultipleConstraintsHaveBeenPassedInToBeApplied() { SolrNetFacetTestFramework.RunSolrUrlCreationTest(@"http://localhost:8983/solr/select?q=*:*&rows=100000000&fq={!tag=brandsfilter}brand_f:(iPhone)&facet=true&facet.field={!key=brands+ex=brandsfilter}brand_f&version=2.2", solr => { var querystring = new NameValueCollection { {"fb", "Smartphones"}, {"fb", "iPhone"}, {"fb", "LCD televisions"}, {"fb", "LED televisions"} }; var queryOptions = new QueryOptions(); var facet = new BrandFacet(querystring, true); facet.BuildQuery(queryOptions); return solr.Query(SolrQuery.All, queryOptions); }); }
public void CreateAFacetWithNoConstraintsApplied() { SolrNetFacetTestFramework.RunSolrUrlCreationTest(@"http://localhost:8983/solr/select?q=*:*&rows=100000000&facet=true&facet.field={!key=brands}brand_f&version=2.2", solr => { var queryOptions = new QueryOptions(); var facet = new BrandFacet(new NameValueCollection()); facet.BuildQuery(queryOptions); return solr.Query(SolrQuery.All, queryOptions); }); }
public void CreateAFacetWithMultipleConstraintAppliedWhereQueryParametersAreSortedInOrder() { SolrNetFacetTestFramework.RunSolrUrlCreationTest(@"http://localhost:8983/solr/select?q=*:*&rows=100000000&fq={!tag=brandsfilter}brand_f:(iPhone+OR+LCD+televisions+OR+LED+televisions+OR+Smartphones)&facet=true&facet.field={!key=brands+ex=brandsfilter}brand_f&version=2.2", solr => { var queryOptions = new QueryOptions(); var facet = new BrandFacet(new NameValueCollection { {"fb", "Smartphones"}, {"fb", "iPhone"}, {"fb", "LCD televisions"}, {"fb", "LED televisions"} }); facet.BuildQuery(queryOptions); return solr.Query(SolrQuery.All, queryOptions); }); }
public void BuildThreeFacetsViewModelsThatAllHaveOneConstraintApplied() { var results = SolrNetFacetTestFramework.RunSolrGetResults( "<?xml version=\"1.0\" encoding=\"UTF-8\"?><response><lst name=\"responseHeader\"><int name=\"status\">0</int><int name=\"QTime\">5</int><lst name=\"params\"><str name=\"facet\">true</str><arr name=\"facet.query\"><str>{!label=500-600 ex=unitpricefilter}unitprice:[500 TO 600]</str><str>{!label=601-1000 ex=unitpricefilter}unitprice:[601 TO 1000]</str><str>{!label=500-600-ruledout ex=brandsfilter,manufacturersfilter,unitpricefilter}unitprice:[500 TO 600]</str><str>{!label=601-1000-ruledout ex=brandsfilter,manufacturersfilter,unitpricefilter}unitprice:[601 TO 1000]</str></arr><str name=\"q\">*:*</str><arr name=\"facet.field\"><str>{!key=brands ex=brandsfilter}brand_f</str><str>{!key=brandsruledout ex=manufacturersfilter,unitpricefilter,brandsfilter}brand_f</str><str>{!key=manufacturers ex=manufacturersfilter}manufacturer_f</str><str>{!key=manufacturersruledout ex=brandsfilter,unitpricefilter,manufacturersfilter}manufacturer_f</str></arr><arr name=\"fq\"><str>{!tag=brandsfilter}brand_f:(Smartphones)</str><str>{!tag=manufacturersfilter}manufacturer_f:(Samsung)</str><str>{!tag=unitpricefilter}unitprice:([500 TO 600])</str></arr><str name=\"version\">2.2</str><str name=\"rows\">100000000</str></lst></lst><result name=\"response\" numFound=\"1\" start=\"0\"><doc><str name=\"id\">65538</str><str name=\"categoryid\">32770</str><float name=\"unitprice\">523.0</float><str name=\"unitprice_c\">523.0000,USD</str><str name=\"name\">Galaxy Note</str><str name=\"url\">home/electronics/phones/galaxy-note</str><long name=\"_version_\">1435991846240124928</long></doc></result><lst name=\"facet_counts\"><lst name=\"facet_queries\"><int name=\"{!label=500-600 ex=unitpricefilter}unitprice:[500 TO 600]\">1</int><int name=\"{!label=601-1000 ex=unitpricefilter}unitprice:[601 TO 1000]\">0</int><int name=\"{!label=500-600-ruledout ex=brandsfilter,manufacturersfilter,unitpricefilter}unitprice:[500 TO 600]\">3</int><int name=\"{!label=601-1000-ruledout ex=brandsfilter,manufacturersfilter,unitpricefilter}unitprice:[601 TO 1000]\">0</int></lst><lst name=\"facet_fields\"><lst name=\"brands\"><int name=\"Smartphones\">1</int><int name=\"LCD televisions\">0</int><int name=\"LED televisions\">0</int><int name=\"Mobile phones\">0</int><int name=\"Plasma televisions\">0</int><int name=\"iPad\">0</int><int name=\"iPhone\">0</int></lst><lst name=\"brandsruledout\"><int name=\"iPhone\">5</int><int name=\"iPad\">3</int><int name=\"Mobile phones\">2</int><int name=\"Smartphones\">2</int><int name=\"LCD televisions\">1</int><int name=\"LED televisions\">1</int><int name=\"Plasma televisions\">1</int></lst><lst name=\"manufacturers\"><int name=\"Samsung\">1</int><int name=\"Apple\">0</int></lst><lst name=\"manufacturersruledout\"><int name=\"Apple\">8</int><int name=\"Samsung\">7</int></lst></lst><lst name=\"facet_dates\"/><lst name=\"facet_ranges\"/></lst></response>", @"http://localhost:8983/solr/select?q=*:*&rows=100000000&fq={!tag=brandsfilter}brand_f:(Smartphones)&fq={!tag=manufacturersfilter}manufacturer_f:(Samsung)&fq={!tag=unitpricefilter}unitprice:([500 TO 600])&facet=true&facet.field={!key=brands ex=brandsfilter}brand_f&facet.field={!key=brandsruledout ex=manufacturersfilter,unitpricefilter,brandsfilter}brand_f&facet.field={!key=manufacturers ex=manufacturersfilter}manufacturer_f&facet.field={!key=manufacturersruledout ex=brandsfilter,unitpricefilter,manufacturersfilter}manufacturer_f&facet.query={!label=500-600 ex=unitpricefilter}unitprice:[500 TO 600]&facet.query={!label=601-1000 ex=unitpricefilter}unitprice:[601 TO 1000]&facet.query={!label=500-600-ruledout ex=brandsfilter,manufacturersfilter,unitpricefilter}unitprice:[500 TO 600]&facet.query={!label=601-1000-ruledout ex=brandsfilter,manufacturersfilter,unitpricefilter}unitprice:[601 TO 1000]&version=2.2"); var querystring = new NameValueCollection { {"fb", "Smartphones"}, {"fm", "Samsung"}, {"fps", "500"}, {"fpl", "600"} }; var brandFacet = new BrandFacet(querystring); var manufacturerFacet = new ManufacturerFacet(querystring); var priceFacet = new PriceFacet(querystring, false, new RangeQuery("500", "600"), new RangeQuery("601", "1000")); var facets = new IFacet[] { brandFacet, manufacturerFacet, priceFacet }; brandFacet.BuildDependencies(facets); manufacturerFacet.BuildDependencies(facets); priceFacet.BuildDependencies(facets); var brandFacetViewModel = brandFacet.BuildViewModel(results); var manufacturerFacetViewModel = manufacturerFacet.BuildViewModel(results); var priceFacetViewModel = priceFacet.BuildViewModel(results); var expectedBrandValues = new[] { new { IsApplied = false, IsDisabled = true, Count = 3, Name = "iPad", Url = string.Empty }, new { IsApplied = false, IsDisabled = true, Count = 5, Name = "iPhone", Url = string.Empty }, new { IsApplied = false, IsDisabled = true, Count = 1, Name = "LCD televisions", Url = string.Empty }, new { IsApplied = false, IsDisabled = true, Count = 1, Name = "LED televisions", Url = string.Empty }, new { IsApplied = false, IsDisabled = true, Count = 2, Name = "Mobile phones", Url = string.Empty }, new { IsApplied = false, IsDisabled = true, Count = 1, Name = "Plasma televisions", Url = string.Empty }, new { IsApplied = true, IsDisabled = false, Count = 1, Name = "Smartphones", Url = "/?fm=Samsung&fps=500&fpl=600" } }; Assert.AreEqual(7, brandFacetViewModel.Constraints.Length); for (var index = 0; index < brandFacetViewModel.Constraints.Length; index++) { Assert.AreEqual(expectedBrandValues[index].IsApplied, brandFacetViewModel.Constraints[index].IsApplied); Assert.AreEqual(expectedBrandValues[index].IsDisabled, brandFacetViewModel.Constraints[index].IsDisabled); Assert.AreEqual(expectedBrandValues[index].Count, brandFacetViewModel.Constraints[index].Count); Assert.AreEqual(expectedBrandValues[index].Name, brandFacetViewModel.Constraints[index].Name); Assert.AreEqual(expectedBrandValues[index].Url, brandFacetViewModel.Constraints[index].Url); } var expectedManufacturerValues = new[] { new { IsApplied = false, IsDisabled = true, Count = 8, Name = "Apple", Url = string.Empty }, new { IsApplied = true, IsDisabled = false, Count = 1, Name = "Samsung", Url = "/?fb=Smartphones&fps=500&fpl=600" } }; Assert.AreEqual(2, manufacturerFacetViewModel.Constraints.Length); for (var index = 0; index < manufacturerFacetViewModel.Constraints.Length; index++) { Assert.AreEqual(expectedManufacturerValues[index].IsApplied, manufacturerFacetViewModel.Constraints[index].IsApplied); Assert.AreEqual(expectedManufacturerValues[index].IsDisabled, manufacturerFacetViewModel.Constraints[index].IsDisabled); Assert.AreEqual(expectedManufacturerValues[index].Count, manufacturerFacetViewModel.Constraints[index].Count); Assert.AreEqual(expectedManufacturerValues[index].Name, manufacturerFacetViewModel.Constraints[index].Name); Assert.AreEqual(expectedManufacturerValues[index].Url, manufacturerFacetViewModel.Constraints[index].Url); } var expectedPriceValues = new[] { new { IsApplied = true, IsDisabled = false, Count = 1, Name = string.Format("{0}500.00 - {0}600.00", NumberFormatInfo.CurrentInfo.CurrencySymbol), Url = "/?fb=Smartphones&fm=Samsung" }, new { IsApplied = false, IsDisabled = true, Count = 0, Name = string.Format("{0}601.00 - {0}1,000.00", NumberFormatInfo.CurrentInfo.CurrencySymbol), Url = string.Empty } }; Assert.AreEqual(2, priceFacetViewModel.Constraints.Length); for (var index = 0; index < priceFacetViewModel.Constraints.Length; index++) { Assert.AreEqual(expectedPriceValues[index].IsApplied, priceFacetViewModel.Constraints[index].IsApplied); Assert.AreEqual(expectedPriceValues[index].IsDisabled, priceFacetViewModel.Constraints[index].IsDisabled); Assert.AreEqual(expectedPriceValues[index].Count, priceFacetViewModel.Constraints[index].Count); Assert.AreEqual(expectedPriceValues[index].Name, priceFacetViewModel.Constraints[index].Name); Assert.AreEqual(expectedPriceValues[index].Url, priceFacetViewModel.Constraints[index].Url); } }
public void BuildSingleSelectionFacetViewModelThatWillOnlyApplyTheFirstConstraintWhenMultipleConstraintsHaveBeenPassedInToBeApplied() { var results = SolrNetFacetTestFramework.RunSolrGetResults( "<?xml version=\"1.0\" encoding=\"UTF-8\"?><response><lst name=\"responseHeader\"><int name=\"status\">0</int><int name=\"QTime\">1</int><lst name=\"params\"><str name=\"facet\">true</str><str name=\"q\">*:*</str><str name=\"facet.field\">{!key=brands ex=brandsfilter}brand_f</str><str name=\"fq\">{!tag=brandsfilter}brand_f:(iPhone)</str><str name=\"version\">2.2</str><str name=\"rows\">100000000</str></lst></lst><result name=\"response\" numFound=\"5\" start=\"0\"><doc><str name=\"id\">65536</str><str name=\"categoryid\">32770</str><float name=\"unitprice\">100.0</float><str name=\"unitprice_c\">100.0000,USD</str><str name=\"name\">iPhone</str><str name=\"url\">home/electronics/phones/iphone</str><long name=\"_version_\">1435991846256902144</long></doc><doc><str name=\"id\">65537</str><str name=\"categoryid\">32770</str><float name=\"unitprice\">200.0</float><str name=\"unitprice_c\">200.0000,USD</str><str name=\"name\">iPhone3G</str><str name=\"url\">home/electronics/phones/iphone3g</str><long name=\"_version_\">1435991846263193600</long></doc><doc><str name=\"id\">65540</str><str name=\"categoryid\">32770</str><float name=\"unitprice\">250.0</float><str name=\"unitprice_c\">250.0000,USD</str><str name=\"name\">iPhone3GS</str><str name=\"url\">home/electronics/phones/iphone3gs</str><long name=\"_version_\">1435991846267387904</long></doc><doc><str name=\"id\">65541</str><str name=\"categoryid\">32770</str><float name=\"unitprice\">350.0</float><str name=\"unitprice_c\">350.0000,USD</str><str name=\"name\">iPhone4</str><str name=\"url\">home/electronics/phones/iphone4</str><long name=\"_version_\">1435991846272630784</long></doc><doc><str name=\"id\">65539</str><str name=\"categoryid\">32770</str><float name=\"unitprice\">550.0</float><str name=\"unitprice_c\">550.0000,USD</str><str name=\"name\">iPhone4S</str><str name=\"url\">home/electronics/phones/iphone4s</str><long name=\"_version_\">1435991846277873664</long></doc></result><lst name=\"facet_counts\"><lst name=\"facet_queries\"/><lst name=\"facet_fields\"><lst name=\"brands\"><int name=\"iPhone\">5</int><int name=\"iPad\">3</int><int name=\"Mobile phones\">2</int><int name=\"Smartphones\">2</int><int name=\"LCD televisions\">1</int><int name=\"LED televisions\">1</int><int name=\"Plasma televisions\">1</int></lst></lst><lst name=\"facet_dates\"/><lst name=\"facet_ranges\"/></lst></response>", @"http://localhost:8983/solr/select?q=*:*&rows=100000000&fq={!tag=brandsfilter}brand_f:(iPhone)&facet=true&facet.field={!key=brands+ex=brandsfilter}brand_f&version=2.2"); var querystring = new NameValueCollection { {"fb", "Smartphones"}, {"fb", "iPhone"}, {"fb", "LCD televisions"}, {"fb", "LED televisions"} }; var queryOptions = new QueryOptions(); var brandFacet = new BrandFacet(querystring, true); brandFacet.BuildQuery(queryOptions); var brandFacetViewModel = brandFacet.BuildViewModel(results); var expectedBrandValues = new[] { new { IsApplied = false, IsDisabled = true, Count = 3, Name = "iPad", Url = string.Empty }, new { IsApplied = true, IsDisabled = false, Count = 5, Name = "iPhone", Url = "/" }, new { IsApplied = false, IsDisabled = true, Count = 1, Name = "LCD televisions", Url = string.Empty }, new { IsApplied = false, IsDisabled = true, Count = 1, Name = "LED televisions", Url = string.Empty }, new { IsApplied = false, IsDisabled = true, Count = 2, Name = "Mobile phones", Url = string.Empty }, new { IsApplied = false, IsDisabled = true, Count = 1, Name = "Plasma televisions", Url = string.Empty }, new { IsApplied = false, IsDisabled = true, Count = 2, Name = "Smartphones", Url = string.Empty } }; Assert.AreEqual(7, brandFacetViewModel.Constraints.Length); for (var index = 0; index < brandFacetViewModel.Constraints.Length; index++) { Assert.AreEqual(expectedBrandValues[index].IsApplied, brandFacetViewModel.Constraints[index].IsApplied); Assert.AreEqual(expectedBrandValues[index].IsDisabled, brandFacetViewModel.Constraints[index].IsDisabled); Assert.AreEqual(expectedBrandValues[index].Count, brandFacetViewModel.Constraints[index].Count); Assert.AreEqual(expectedBrandValues[index].Name, brandFacetViewModel.Constraints[index].Name); Assert.AreEqual(expectedBrandValues[index].Url, brandFacetViewModel.Constraints[index].Url); } }
public void BuildAMultipleSelectFacetViewModelWithNoConstraintsApplied() { var results = SolrNetFacetTestFramework.RunSolrGetResults( "<?xml version=\"1.0\" encoding=\"UTF-8\"?><response><lst name=\"responseHeader\"><int name=\"status\">0</int><int name=\"QTime\">1</int><lst name=\"params\"><str name=\"facet\">true</str><str name=\"q\">*:*</str><str name=\"facet.field\">{!key=brands}brand_f</str><str name=\"version\">2.2</str><str name=\"rows\">100000000</str></lst></lst><result name=\"response\" numFound=\"15\" start=\"0\"><doc><str name=\"id\">65547</str><str name=\"categoryid\">32772</str><float name=\"unitprice\">1699.99</float><str name=\"unitprice_c\">1699.9900,USD</str><str name=\"name\">19\" D450 HD LCD TV</str><str name=\"url\">home/electronics/televisions/19-d450-hd-lcd-tv</str><long name=\"_version_\">1435991846184550400</long></doc><doc><str name=\"id\">65545</str><str name=\"categoryid\">32772</str><float name=\"unitprice\">1399.99</float><str name=\"unitprice_c\">1399.9900,USD</str><str name=\"name\">32'' ES6800 Series 6 SMART 3D Full HD LED TV</str><str name=\"url\">home/electronics/televisions/32-es6800-series-6-smart-3d-full-hd-led-tv</str><long name=\"_version_\">1435991846228590592</long></doc><doc><str name=\"id\">65550</str><str name=\"categoryid\">32772</str><float name=\"unitprice\">1299.99</float><str name=\"unitprice_c\">1299.9900,USD</str><str name=\"name\">51\" E6500 Series 6 Smart Full HD LED TV</str><str name=\"url\">home/electronics/televisions/51-e6500-series-6-smart-full-hd-led-tv</str><long name=\"_version_\">1435991846231736320</long></doc><doc><str name=\"id\">65546</str><str name=\"categoryid\">32770</str><float name=\"unitprice\">127.99</float><str name=\"unitprice_c\">127.9900,USD</str><str name=\"name\">Curvy Simplicity</str><str name=\"url\">home/electronics/phones/curvy-simplicity</str><long name=\"_version_\">1435991846235930624</long></doc><doc><str name=\"id\">65538</str><str name=\"categoryid\">32770</str><float name=\"unitprice\">523.0</float><str name=\"unitprice_c\">523.0000,USD</str><str name=\"name\">Galaxy Note</str><str name=\"url\">home/electronics/phones/galaxy-note</str><long name=\"_version_\">1435991846240124928</long></doc><doc><str name=\"id\">65542</str><str name=\"categoryid\">32771</str><float name=\"unitprice\">250.0</float><str name=\"unitprice_c\">250.0000,USD</str><str name=\"name\">iPad</str><str name=\"url\">home/electronics/tablets/ipad</str><long name=\"_version_\">1435991846244319232</long></doc><doc><str name=\"id\">65543</str><str name=\"categoryid\">32771</str><float name=\"unitprice\">350.0</float><str name=\"unitprice_c\">350.0000,USD</str><str name=\"name\">iPad2</str><str name=\"url\">home/electronics/tablets/ipad2</str><long name=\"_version_\">1435991846248513536</long></doc><doc><str name=\"id\">65544</str><str name=\"categoryid\">32771</str><float name=\"unitprice\">500.0</float><str name=\"unitprice_c\">500.0000,USD</str><str name=\"name\">iPad3</str><str name=\"url\">home/electronics/tablets/ipad3</str><long name=\"_version_\">1435991846252707840</long></doc><doc><str name=\"id\">65536</str><str name=\"categoryid\">32770</str><float name=\"unitprice\">100.0</float><str name=\"unitprice_c\">100.0000,USD</str><str name=\"name\">iPhone</str><str name=\"url\">home/electronics/phones/iphone</str><long name=\"_version_\">1435991846256902144</long></doc><doc><str name=\"id\">65537</str><str name=\"categoryid\">32770</str><float name=\"unitprice\">200.0</float><str name=\"unitprice_c\">200.0000,USD</str><str name=\"name\">iPhone3G</str><str name=\"url\">home/electronics/phones/iphone3g</str><long name=\"_version_\">1435991846263193600</long></doc><doc><str name=\"id\">65540</str><str name=\"categoryid\">32770</str><float name=\"unitprice\">250.0</float><str name=\"unitprice_c\">250.0000,USD</str><str name=\"name\">iPhone3GS</str><str name=\"url\">home/electronics/phones/iphone3gs</str><long name=\"_version_\">1435991846267387904</long></doc><doc><str name=\"id\">65541</str><str name=\"categoryid\">32770</str><float name=\"unitprice\">350.0</float><str name=\"unitprice_c\">350.0000,USD</str><str name=\"name\">iPhone4</str><str name=\"url\">home/electronics/phones/iphone4</str><long name=\"_version_\">1435991846272630784</long></doc><doc><str name=\"id\">65539</str><str name=\"categoryid\">32770</str><float name=\"unitprice\">550.0</float><str name=\"unitprice_c\">550.0000,USD</str><str name=\"name\">iPhone4S</str><str name=\"url\">home/electronics/phones/iphone4s</str><long name=\"_version_\">1435991846277873664</long></doc><doc><str name=\"id\">65548</str><str name=\"categoryid\">32770</str><float name=\"unitprice\">270.0</float><str name=\"unitprice_c\">270.0000,USD</str><str name=\"name\">Omina W</str><str name=\"url\">home/electronics/phones/omina-w</str><long name=\"_version_\">1435991846282067968</long></doc><doc><str name=\"id\">65549</str><str name=\"categoryid\">32770</str><float name=\"unitprice\">78.99</float><str name=\"unitprice_c\">78.9900,USD</str><str name=\"name\">Solid Xcover</str><str name=\"url\">home/electronics/phones/solid-xcover</str><long name=\"_version_\">1435991846286262272</long></doc></result><lst name=\"facet_counts\"><lst name=\"facet_queries\"/><lst name=\"facet_fields\"><lst name=\"brands\"><int name=\"iPhone\">5</int><int name=\"iPad\">3</int><int name=\"Mobile phones\">2</int><int name=\"Smartphones\">2</int><int name=\"LCD televisions\">1</int><int name=\"LED televisions\">1</int><int name=\"Plasma televisions\">1</int></lst></lst><lst name=\"facet_dates\"/><lst name=\"facet_ranges\"/></lst></response>", @"http://localhost:8983/solr/select?q=*:*&rows=100000000&facet=true&facet.field={!key=brands}brand_f&version=2.2"); var brandFacet = new BrandFacet(new NameValueCollection(), true); var facetViewModel = brandFacet.BuildViewModel(results); var expectedValues = new[] { new { IsApplied = false, IsDisabled = false, Count = 3, Name = "iPad", Url = "/?fb=iPad" }, new { IsApplied = false, IsDisabled = false, Count = 5, Name = "iPhone", Url = "/?fb=iPhone" }, new { IsApplied = false, IsDisabled = false, Count = 1, Name = "LCD televisions", Url = "/?fb=LCD+televisions" }, new { IsApplied = false, IsDisabled = false, Count = 1, Name = "LED televisions", Url = "/?fb=LED+televisions" }, new { IsApplied = false, IsDisabled = false, Count = 2, Name = "Mobile phones", Url = "/?fb=Mobile+phones" }, new { IsApplied = false, IsDisabled = false, Count = 1, Name = "Plasma televisions", Url = "/?fb=Plasma+televisions" }, new { IsApplied = false, IsDisabled = false, Count = 2, Name = "Smartphones", Url = "/?fb=Smartphones" } }; Assert.AreEqual(7, facetViewModel.Constraints.Length); for (var index = 0; index < facetViewModel.Constraints.Length; index++) { Assert.AreEqual(expectedValues[index].IsApplied, facetViewModel.Constraints[index].IsApplied); Assert.AreEqual(expectedValues[index].IsDisabled, facetViewModel.Constraints[index].IsDisabled); Assert.AreEqual(expectedValues[index].Count, facetViewModel.Constraints[index].Count); Assert.AreEqual(expectedValues[index].Name, facetViewModel.Constraints[index].Name); Assert.AreEqual(expectedValues[index].Url, facetViewModel.Constraints[index].Url); } }