当前位置: 首页>>代码示例>>C#>>正文


C# QueryOptions.AddFacets方法代码示例

本文整理汇总了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));
            }
        }
开发者ID:mondok,项目名称:Solr-Baseball-Stats-Demo,代码行数:37,代码来源:QueryExamples.cs

示例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());
            }
        }
开发者ID:dezzy30000,项目名称:dukaan,代码行数:23,代码来源:RangeFacetBuilder.cs


注:本文中的QueryOptions.AddFacets方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。