本文整理汇总了C#中QueryOptions.AddFacets方法的典型用法代码示例。如果您正苦于以下问题:C# QueryOptions.AddFacets方法的具体用法?C# QueryOptions.AddFacets怎么用?C# QueryOptions.AddFacets使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QueryOptions
的用法示例。
在下文中一共展示了QueryOptions.AddFacets方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RunFacetExample
public void RunFacetExample()
{
Console.WriteLine("-- RunFacetExample --");
FacetParameters facetParameters = new FacetParameters();
QueryOptions queryOptions = new QueryOptions();
SolrFacetFieldQuery umpireFacets = new SolrFacetFieldQuery("bg_homePlateUmpire");
umpireFacets.Limit = 50;
umpireFacets.Sort = true;
// this uses the DateMathParser syntax - i.e. +1DAY, +1MONTH, DAY+6MONTHS+3DAYS
SolrFacetDateQuery dateFacets = new SolrFacetDateQuery("bg_date", new DateTime(2005, 1, 1), DateTime.Now, "+1MONTH");
queryOptions.AddFacets(umpireFacets, dateFacets);
// we just want the facets, not data
queryOptions.Rows = 0;
ISolrQueryResults<BaseballGame> results = _solrOperations.Query(SolrQuery.All, queryOptions);
DateFacetingResult dateFacetResults = results.FacetDates["bg_date"];
var umpireFacetResults = results.FacetFields["bg_homePlateUmpire"];
Console.WriteLine("Date Facets");
foreach (KeyValuePair<DateTime,int> dateFacet in dateFacetResults.DateResults)
{
Console.WriteLine(string.Format("Date: {0}, Games: {1}", dateFacet.Key, dateFacet.Value));
}
Console.WriteLine("Umpire Facets");
foreach(KeyValuePair<string,int> umpireFacet in umpireFacetResults)
{
Console.WriteLine(string.Format("Umpire Name: {0}, Games Called: {1}", umpireFacet.Key, umpireFacet.Value));
}
}
示例2: BuildQuery
public void BuildQuery(QueryOptions queryOptions)
{
string excludes;
if (FacetIsApplied())
{
queryOptions
.AddFilterQueries(BuildFilterQuery());
}
queryOptions
.AddFacets(_ranges
.Select(range => range.BuildFacetQuery(_solrField, _filterQueryTag, FacetIsApplied()))
.ToArray());
if (WeHaveExclusionFilters(_facets, out excludes))
{
queryOptions
.AddFacets(_ranges
.Select(range => range.BuildFacetQuery(_solrField, excludes))
.ToArray());
}
}