本文整理汇总了C#中SolrQuery.RangeFacetFor方法的典型用法代码示例。如果您正苦于以下问题:C# SolrQuery.RangeFacetFor方法的具体用法?C# SolrQuery.RangeFacetFor怎么用?C# SolrQuery.RangeFacetFor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SolrQuery
的用法示例。
在下文中一共展示了SolrQuery.RangeFacetFor方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Facet1Async
public async Task Facet1Async()
{
var termsFacetFor = new SolrQuery<TechProduct>().SearchFor("*", "lucene").Take(0).TermsFacetFor(x => x.Category);
termsFacetFor = termsFacetFor.RangeFacetFor(x => x.Popularity, x => x.Range(5, 10, "1"));
termsFacetFor = termsFacetFor.RangeFacetFor(x => x.ManufactureDate,
x =>
x.Range(DateTime.Now.AddYears(-20), DateTime.Now, "+1YEAR")
.TermsFacetFor(y => y.Category,
y => y.RangeFacetFor(z => z.Popularity, z => z.Range(5, 10, "1"))));
var searchResult = await _repository.SearchAsync(termsFacetFor);
var bucket = searchResult.Raw.Facets["R2"]["buckets"].ToList()[10]["T0"]["buckets"].ToList()[0]["R0"]["buckets"].ToList()[1];
Assert.AreEqual(6, bucket["val"]);
Assert.AreEqual(2, bucket["count"]);
//var facetC = new SolrQueryStatisticsFacet<TechProduct>("unique(cat)");
//var facetA = new SolrQueryTermsFacet<TechProduct>(x => x.Category).Facet("D", facetC);
//var facetB = new SolrQueryTermsFacet<TechProduct>(x => x.LastModified).Facet("D", facetC);
//var query = new SolrQuery<TechProduct>().Take(0).Facet("A", facetA).Facet("B", facetB).Facet("C", facetC);
//var r3 = await _repository.Get(query);
//Assert.AreEqual(0, r3.Response.Documents.Count());
//var facets = r3.GetFacets();
//Assert.AreEqual(37, (long)r3.Facets["count"]);
//var facetObject = (JObject)r3.Facets["A"];
//var dic = facetObject.ToObject<IDictionary>();
//Assert.AreNotEqual(null, dic);
}