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


C# QueryOptions.AddFilterQueries方法代码示例

本文整理汇总了C#中QueryOptions.AddFilterQueries方法的典型用法代码示例。如果您正苦于以下问题:C# QueryOptions.AddFilterQueries方法的具体用法?C# QueryOptions.AddFilterQueries怎么用?C# QueryOptions.AddFilterQueries使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QueryOptions的用法示例。


在下文中一共展示了QueryOptions.AddFilterQueries方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GroupingSerach

 /// <summary>
 /// </summary>
 /// <param name="dictPars">查询参数字典</param>
 /// <param name="start">分页开始标识</param>
 /// <param name="rows">每页数量</param>
 /// <param name="startTime">开始时间</param>
 /// <param name="endTime">结束时间</param>
 /// <param name="count">输出参数 总个数</param>
 /// <returns></returns>
 /// <remarks>peng.li 2015年7月23日14:11:43</remarks>
 public static List<int> GroupingSerach(Dictionary<string, string> dictPars, int start, int rows,
     DateTime startTime, DateTime endTime, out int count)
 {
     //定义solr
     var solr = ServiceLocator.Current.GetInstance<ISolrOperations<LogItems>>();
     var queryOptions = new QueryOptions();
     //定义分组
     var groupingParameters = new GroupingParameters();
     groupingParameters.Fields = new Collection<string> { "logs_id" };
     groupingParameters.Ngroups = true; //设置查询分组的总个数为true
     //定义过滤条件
     var timeRange = new SolrQueryByRange<DateTime>("logs_time", startTime, endTime);
     queryOptions.AddFilterQueries(timeRange);
     foreach (string key in dictPars.Keys)
     {
         queryOptions.AddFilterQueries(new SolrQueryByField(key, dictPars[key]));
     }
     //定义排序
     queryOptions.OrderBy = new Collection<SortOrder> { new SortOrder("logs_id", Order.DESC) };
     queryOptions.Grouping = groupingParameters;
     queryOptions.Start = start;
     queryOptions.Rows = rows;
     SolrQueryResults<LogItems> res = solr.Query(SolrQuery.All, queryOptions);
     GroupedResults<LogItems> items = res.Grouping["logs_id"];
     count = items.Ngroups ?? 0;
     return items.Groups.Select(item => Convert.ToInt32(item.GroupValue)).ToList();
 }
开发者ID:xiaopohou,项目名称:SolrDemo,代码行数:37,代码来源:SolrNetOperate.cs

示例2: ExecuteQuery

        public ISolrQueryResults<BaseballGame> ExecuteQuery()
        {
            List<ISolrQuery> fieldQueries = new List<ISolrQuery>();
            QueryOptions options = new QueryOptions();
            options.Facet = BuildBaseFacetQuery();
            options.Rows = 200;

            if (this.AppliedFacets.Count > 0)
            {
                var facetGroups = this.AppliedFacets.Select(t => t.Item1).Distinct().ToList();

                foreach(var group in facetGroups)
                {
                    List<ISolrQuery> queries = this.AppliedFacets.Where(fg => fg.Item1 == group).Select(q => new SolrQueryByField(q.Item1, q.Item2) as ISolrQuery).ToList();
                    SolrMultipleCriteriaQuery smcq =
                        new SolrMultipleCriteriaQuery(queries,"OR");
                    fieldQueries.Add(smcq);
                }

                ISolrQuery multipleCriteriaQuery = new SolrMultipleCriteriaQuery(fieldQueries, "AND");
                options.AddFilterQueries(multipleCriteriaQuery);
            }
            options.OrderBy.Add(new SortOrder(this.CurrentSortTerm, this.SortDirection == "D" ? Order.DESC : Order.ASC));
            options.AddFilterQueries(new SolrQueryByField("docType", DocType.BaseballGame.ToString()));
            ISolrQuery finalQuery = SolrQuery.All;

            if (!string.IsNullOrEmpty(this.SearchTerm))
            {
                finalQuery = new SolrQuery(this.SearchTerm);
            }

            return _solrOperations.Query(finalQuery, options);
        }
开发者ID:mondok,项目名称:Solr-Baseball-Stats-Demo,代码行数:33,代码来源:BaseballQueryBuilder.cs

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