• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# ISearchCriteria类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ISearchCriteria的典型用法代码示例。如果您正苦于以下问题:C# ISearchCriteria类的具体用法?C# ISearchCriteria怎么用?C# ISearchCriteria使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ISearchCriteria类属于命名空间,在下文中一共展示了ISearchCriteria类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: LuceneSearchResults

 /// <summary>
 ///     Initializes a new instance of the <see cref="SearchResults" /> class.
 /// </summary>
 /// <param name="searcher">The searcher.</param>
 /// <param name="reader">The reader.</param>
 /// <param name="docs">The hits.</param>
 /// <param name="criteria">The criteria.</param>
 /// <param name="query">The query.</param>
 public LuceneSearchResults(Searcher searcher, IndexReader reader, TopDocs docs, ISearchCriteria criteria, Query query)
 {
     Results = new SearchResults(criteria, null);
     CreateDocuments(searcher, docs);
     CreateFacets(reader, query);
     CreateSuggestions(reader, criteria);
 }
开发者ID:sameerkattel,项目名称:vc-community,代码行数:15,代码来源:LuceneSearchResults.cs


示例2: BuildQuery

        /// <summary>
        ///     Builds the query.
        /// </summary>
        /// <param name="criteria">The criteria.</param>
        /// <returns></returns>
        public virtual object BuildQuery(ISearchCriteria criteria)
        {
            var query = new BooleanQuery();

            if (criteria.CurrentFilterValues != null)
            {
                for (var index = 0; index < criteria.CurrentFilterFields.Length; index++)
                {
                    var filter = criteria.CurrentFilters.ElementAt(index);
                    var value = criteria.CurrentFilterValues.ElementAt(index);
                    var field = criteria.CurrentFilterFields.ElementAt(index);

                    // Skip currencies that are not part of the filter
                    if (filter.GetType() == typeof(PriceRangeFilter)) // special filtering 
                    {
                        var currency = (filter as PriceRangeFilter).Currency;
                        if (!currency.Equals(criteria.Currency, StringComparison.OrdinalIgnoreCase))
                        {
                            continue;
                        }
                    }

                    var filterQuery = filter.GetType() == typeof(PriceRangeFilter)
                                          ? LuceneQueryHelper.CreateQuery(criteria, field, value as RangeFilterValue)
                                          : LuceneQueryHelper.CreateQuery(field, value);

                    if (filterQuery != null)
                    {
                        query.Add(filterQuery, Occur.MUST);
                    }
                }
            }

            return query;
        }
开发者ID:karpinskiy,项目名称:vc-community,代码行数:40,代码来源:BaseSearchQueryBuilder.cs


示例3: CreateQueryForValue

        public static BoolFilter<ESDocument> CreateQueryForValue(ISearchCriteria criteria, ISearchFilter filter, ISearchFilterValue value)
        {
            var query = new BoolFilter<ESDocument>();
            var field = filter.Key.ToLower();
            if (filter.GetType() == typeof(PriceRangeFilter))
            {
                var tempQuery = CreatePriceRangeFilter(criteria, field, value as RangeFilterValue);
                if (tempQuery != null)
                {
                    query.Must(q => q.Bool(b => tempQuery));
                }
            }
            else
            {
                if (value.GetType() == typeof(AttributeFilterValue))
                {
                    query.Must(q => q.Term(t=>t.Field(field).Value(((AttributeFilterValue)value).Value)));
                }
                else if (value.GetType() == typeof(RangeFilterValue))
                {
                    var tempValue = value as RangeFilterValue;
                    var tempFilter = new RangeFilter<ESDocument>();
                    tempFilter.Field(field).From(tempValue.Lower).To(tempValue.Upper).IncludeLower(true).IncludeUpper(false);
                    query.Should(q => q.Range(r => tempFilter));
                }
            }

            return query;
        }
开发者ID:gitter-badger,项目名称:vc-community-1.x,代码行数:29,代码来源:ElasticQueryHelper.cs


示例4: ExcludedSearchCriteria

        public ExcludedSearchCriteria(ISearchCriteria searchCriteria)
        {
            if (searchCriteria == null)
                throw new ArgumentNullException("searchCriteria");

            this.searchCriteria = searchCriteria;
        }
开发者ID:pulb,项目名称:basenji,代码行数:7,代码来源:ExcludedSearchCriteria.cs


示例5: CatalogItemSearchResults

		public CatalogItemSearchResults(ISearchCriteria criteria, Dictionary<string, Dictionary<string, object>> items, SearchResults results)
		{
			_Items = items;
			_TotalCount = results.TotalCount;
			_Count = results.DocCount;
			_FacetGroups = results.FacetGroups;
			_SearchCriteria = criteria;
		}
开发者ID:adwardliu,项目名称:vc-community,代码行数:8,代码来源:CatalogIndexedSearchResults.cs


示例6: Request

 public Request(ISearchCriteria criteria, int depth, ReceiveResponse callback)
 {
     Identifier = Environment.MachineName + Peer.Self.Name + DateTime.UtcNow;
     SearchCriteria = criteria;
     Requester = Peer.Self;
     Depth = depth;
     Callback = callback;
 }
开发者ID:Sorcha,项目名称:SD-Trabalho1,代码行数:8,代码来源:Request.cs


示例7: SearchCriteriaViewModel

 /// <summary>
 /// Initializes a new instance of the <see cref="SearchCriteriaViewModel"/> class.
 /// </summary>
 /// <param name="criterea">The criterea.</param>
 public SearchCriteriaViewModel(ISearchCriteria criterea)
 {
     if (criterea != null)
     {
         this.SearchFor = criterea.SearchFor;
         this.CategoryID = criterea.CategoryID;
         this.OSID = criterea.OSID;
         this.OrderBy = criterea.OrderBy;
         this.Page = 1;
         //todo: add additional criterea here
     }
 }
开发者ID:eviternity,项目名称:Apps4KidsWebApp,代码行数:16,代码来源:SearchCriteriaViewModel.cs


示例8: CreateQuery

        public static Filter CreateQuery(ISearchCriteria criteria, ISearchFilter filter, Occur clause)
        {
            var values = GetFilterValues(filter);
            if (values == null) return null;

            var query = new BooleanFilter();
            foreach (var value in values)
            {
                var valueQuery = CreateQueryForValue(criteria, filter, value);
                query.Add(new FilterClause(valueQuery, Occur.SHOULD));
            }

            return query;
        }
开发者ID:Wdovin,项目名称:vc-community,代码行数:14,代码来源:LuceneQueryHelper.cs


示例9: SearchOrders

		public OrderSearchResults SearchOrders(string scope, ISearchCriteria criteria)
		{
			var results = _searchService.Search(scope, criteria) as SearchResults;

			if (results != null)
			{
				var resultIds = results.GetKeyFieldValues<string>();

				var orders = _orderRepository.Orders.Where(x => resultIds.Contains(x.OrderGroupId)).ToArray();

				var retVal = new OrderSearchResults(criteria, orders, results);
				return retVal;
			}
			return null;
		}
开发者ID:gitter-badger,项目名称:vc-community-1.x,代码行数:15,代码来源:OrderService.cs


示例10: CreateQuery

        public static BoolFilter<ESDocument> CreateQuery(ISearchCriteria criteria, ISearchFilter filter)
        {
            var values = GetFilterValues(filter);
            if (values == null) return null;

            var query = new BoolFilter<ESDocument>();
            foreach (var value in values)
            {
                var valueQuery = CreateQueryForValue(criteria, filter, value);
                //var boolQuery = new Query<ESDocument>();
                //boolQuery.Bool(x => valueQuery);
                query.Should(x=>x.Bool(y=>valueQuery));
            }

            return query;
        }
开发者ID:gitter-badger,项目名称:vc-community-1.x,代码行数:16,代码来源:ElasticQueryHelper.cs


示例11: Search

        public ISearchResults Search(string scope, ISearchCriteria criteria)
        {
            // Build query
            var builder = (SearchQuery)_queryBuilder.BuildQuery(criteria);

            SearchQueryResult resultDocs;

            // Add some error handling
            //try
            {
                var searchResponse = Client.Search(scope, builder).Result;
                if (!searchResponse.IsSuccess)
                {
                    throw new AzureSearchException(AzureSearchHelper.FormatSearchException(searchResponse));
                }

                resultDocs = searchResponse.Body;
            }
            /*
        catch (Exception ex)
        {
            throw ex;
        }
             * */

            // Parse documents returned
            var documents = new ResultDocumentSet { TotalCount = resultDocs.Count };
            var docList = new List<ResultDocument>();
            foreach (var indexDoc in resultDocs.Records)
            {
                var document = new ResultDocument();
                foreach (var field in indexDoc.Properties.Keys)
                {
                    document.Add(new DocumentField(field, indexDoc.Properties[field]));
                }

                docList.Add(document);
            }

            documents.Documents = docList.ToArray();

            // Create search results object
            var results = new SearchResults(criteria, new[] { documents });

            return results;
        }
开发者ID:adwardliu,项目名称:vc-community,代码行数:46,代码来源:AzureSearchProvider.cs


示例12: CreatePriceRangeFilter

        /// <summary>
        /// Creates the price range filter.
        /// </summary>
        /// <param name="criteria">The criteria.</param>
        /// <param name="field">The field.</param>
        /// <param name="value">The value.</param>
        /// <returns></returns>
        public static BoolFilter<ESDocument> CreatePriceRangeFilter(ISearchCriteria criteria, string field, RangeFilterValue value)
        {
            var query = new BoolFilter<ESDocument>();

            var lowerbound = value.Lower;
            var upperbound = value.Upper;

            var lowerboundincluded = true;
            var upperboundincluded = false;

            var currency = criteria.Currency.ToLower();

            // format is "fieldname_store_currency_pricelist"
            string[] pls = null;
            if (criteria is CatalogItemSearchCriteria)
            {
                pls = ((CatalogItemSearchCriteria)criteria).Pricelists;
            }

            var parentPriceList = String.Empty;

            // Create  filter of type 
            // price_USD_pricelist1:[100 TO 200} (-price_USD_pricelist1:[* TO *} +(price_USD_pricelist2:[100 TO 200} (-price_USD_pricelist2:[* TO *} (+price_USD_pricelist3[100 TO 200}))))

            if (pls == null || pls.Count() == 0)
                return null;

            var priceListId = pls[0].ToLower();

            var filter = new RangeFilter<ESDocument>();
            filter.Field(String.Format("{0}_{1}_{2}", field, currency, priceListId)).From(lowerbound).To(upperbound).IncludeLower(lowerboundincluded).IncludeUpper(upperboundincluded);

            //query.Should(q => q.ConstantScore(c => c.Filter(f => f.Range(r => filter))));
            query.Should(q => q.Range(r => filter));

            if (pls.Count() > 1)
            {
                var temp = CreatePriceRangeFilter(pls, 1, field, currency, lowerbound, upperbound, lowerboundincluded, upperboundincluded);
                query.Should(q => q.Bool(b => temp));
            }

            //Query query = new ConstantScoreQuery(filter);
            return query;
        }
开发者ID:karpinskiy,项目名称:vc-community,代码行数:51,代码来源:ElasticQueryHelper.cs


示例13: CreateQueryForValue

 public static Filter CreateQueryForValue(ISearchCriteria criteria, ISearchFilter filter, ISearchFilterValue value)
 {
     Filter q = null;
     var priceQuery = filter is PriceRangeFilter;
     if (value is RangeFilterValue && priceQuery)
     {
         q = LuceneQueryHelper.CreateQuery(
             criteria, filter.Key, value as RangeFilterValue);
     }
     else if (value is CategoryFilterValue)
     {
         q = CreateQuery(filter.Key, value as CategoryFilterValue);
     }
     else
     {
         q = CreateQuery(filter.Key, value);
     }
     return q;
 }
开发者ID:Wdovin,项目名称:vc-community,代码行数:19,代码来源:LuceneQueryHelper.cs


示例14: CreateQueryForValue

        public static Filter CreateQueryForValue(ISearchCriteria criteria, ISearchFilter filter, ISearchFilterValue value)
        {
            Filter q;
            var priceQuery = filter is PriceRangeFilter;

            var rangeFilterValue = value as RangeFilterValue;
            if (rangeFilterValue != null && priceQuery)
            {
                q = CreateQuery(criteria, filter.Key, rangeFilterValue);
            }
            else if (value is CategoryFilterValue)
            {
                q = CreateQuery(filter.Key, (CategoryFilterValue)value);
            }
            else
            {
                q = CreateQuery(filter.Key, value);
            }

            return q;
        }
开发者ID:sameerkattel,项目名称:vc-community,代码行数:21,代码来源:LuceneQueryHelper.cs


示例15: BuildQuery

    public static ISearchCriteria BuildQuery(string[] textFields, string searchString, ISearchCriteria criteria)
    {
        List<SearchTerm> Terms = new List<SearchTerm>();

        if ((searchString.Contains(@"""")) && (searchString.Count(t => t == '"') % 2 == 0)) // even number of quotes, more than zero
        {
            Regex quoteRegex = new Regex(@""".+?"""); // look for any content between quotes
            foreach (Match item in quoteRegex.Matches(searchString))
            {
                Terms.Add(new SearchTerm() { Term = item.Value.Replace('"', ' ').Trim(), TermType = SearchTermType.MultiWord });
                searchString = Regex.Replace(searchString, item.Value, string.Empty); // remove them from search string for subsequent parsing
            }
        }

        List<string> singleTerms = new List<string>();
        singleTerms = searchString.Split(' ').ToList();
        singleTerms.ForEach(t => Terms.Add(new SearchTerm() { Term = t, TermType = SearchTermType.SingleWord }));

        foreach (SearchTerm t in Terms)
        {
            if (!string.IsNullOrEmpty(t.Term))
            {
                switch (t.TermType)
                {
                    case SearchTermType.SingleWord:
                        criteria.GroupedOr(textFields,
                            new IExamineValue[] { Examine.LuceneEngine.SearchCriteria.LuceneSearchExtensions.Fuzzy(t.Term, 0.4F) });
                        break;
                    case SearchTermType.MultiWord:
                        criteria.GroupedOr(textFields,
                            new IExamineValue[] { Examine.LuceneEngine.SearchCriteria.LuceneSearchExtensions.Escape(t.Term) });
                        break;
                    default:
                        break;
                }
            }
        }

        return criteria;
    }
开发者ID:Interon,项目名称:uMaster,代码行数:40,代码来源:Extensions.cs


示例16: BuildQuery

        public static ISearchCriteria BuildQuery(string searchString, ISearchCriteria criteria, string[] textFields)
        {
            var terms = searchString.ToSearchTerms();

            foreach (var t in terms.Where(t => !string.IsNullOrEmpty(t.Term)))
            {
                switch (t.SearchTermType)
                {
                    case SearchTermType.SingleWord:
                        criteria.GroupedOr(
                            textFields,
                            new[] { t.Term.Fuzzy() });
                        break;
                    case SearchTermType.MultiWord:
                        criteria.GroupedOr(
                            textFields,
                            new[] { t.Term.MultipleCharacterWildcard() });
                        break;
                }
            }

            return criteria;
        }
开发者ID:drpeck,项目名称:Merchello,代码行数:23,代码来源:SearchHelper.cs


示例17: SearchResult

 /// <summary>
 /// Initializes a new instance of the <see cref="SearchResult"/> class.
 /// </summary>
 /// <param name="criterea">The criterea.</param>
 /// <param name="page">The page.</param>
 internal SearchResult(ISearchCriteria criterea = null, int page = 1)
 {
     this.Criterea = criterea;
     using (var context = Connection.GetContext())
     {
         IQueryable<Persistence.App> query =
             context
             .Apps
             .Include("Pictures")
             .Include("Categories")
             .Include("OperatingSystems")
             .Include("Recentions")
             .Include("Recentions.User")
             .Include("Producer");
         if (criterea != null)
         {
              query = QueryByCriterea(query, criterea);
         }
         this.ResultAppCount = query.Count();
         this.Page = page <= Pages && page > 0 ? page : 1;
         if (criterea != null)
         {
             query = query.SortByCritera(criterea);
         }
         else
         {
             query = query.SortByCritera();
         }
         query = query.Skip(APPSPERPAGE * (this.Page - 1)).Take(APPSPERPAGE);
         List<IApp> result = new List<IApp>();
         foreach (var item in query)
         {
             result.Add(new App(item));
         }
         this.Apps = result.ToArray();
     }
 }
开发者ID:eviternity,项目名称:Apps4KidsWebApp,代码行数:42,代码来源:SearchResult.cs


示例18: BuildQuery

        /// <summary>
        ///     Builds the query.
        /// </summary>
        /// <param name="criteria">The criteria.</param>
        /// <returns></returns>
        public virtual object BuildQuery(ISearchCriteria criteria)
        {
            var queryBuilder = new QueryBuilder();
            var queryFilter = new BooleanFilter();
            var query = new BooleanQuery();
            queryBuilder.Query = query;
            queryBuilder.Filter = queryFilter;

            if (criteria.CurrentFilters != null)
            {
                foreach (var filter in criteria.CurrentFilters)
                {
                    // Skip currencies that are not part of the filter
                    if (filter.GetType() == typeof(PriceRangeFilter)) // special filtering 
                    {
                        var currency = (filter as PriceRangeFilter).Currency;
                        if (!currency.Equals(criteria.Currency, StringComparison.OrdinalIgnoreCase))
                        {
                            continue;
                        }
                    }

                    var filterQuery = LuceneQueryHelper.CreateQuery(criteria, filter, Occur.SHOULD);

                    // now add other values that should also be counted?

                    if (filterQuery != null)
                    {
                        var clause = new FilterClause(filterQuery, Occur.MUST);
                        queryFilter.Add(clause);
                    }
                }
            }

            return queryBuilder;
        }
开发者ID:adwardliu,项目名称:vc-community,代码行数:41,代码来源:BaseSearchQueryBuilder.cs


示例19: BuildQuery

        /// <summary>
        ///     Builds the query.
        /// </summary>
        /// <param name="criteria">The criteria.</param>
        /// <returns></returns>
        public override object BuildQuery(ISearchCriteria criteria)
        {

            var builder = base.BuildQuery(criteria) as QueryBuilder;
            var query = builder.Query as BooleanQuery;
            var analyzer = new StandardAnalyzer(u.Version.LUCENE_30);

            if (criteria is CatalogItemSearchCriteria)
            {
                var c = criteria as CatalogItemSearchCriteria;
                var datesFilterStart = new TermRangeQuery(
                    "startdate", c.StartDateFrom.HasValue ? DateTools.DateToString(c.StartDateFrom.Value, DateTools.Resolution.SECOND) : null, DateTools.DateToString(c.StartDate, DateTools.Resolution.SECOND), false, true);
                query.Add(datesFilterStart, Occur.MUST);

                if (c.EndDate.HasValue)
                {
                    var datesFilterEnd = new TermRangeQuery(
                        "enddate",
                        DateTools.DateToString(c.EndDate.Value, DateTools.Resolution.SECOND),
                        null,
                        true,
                        false);

                    query.Add(datesFilterEnd, Occur.MUST);
                }

                if (c.Outlines != null && c.Outlines.Count > 0)
                {
                    AddQuery("__outline", query, c.Outlines);
                }

                query.Add(new TermQuery(new Term("__hidden", "false")), Occur.MUST);

                if (!String.IsNullOrEmpty(c.Catalog))
                {
                    AddQuery("catalog", query, c.Catalog);
                }

                // Add search
                if (!String.IsNullOrEmpty(c.SearchPhrase))
                {
                    if (c.IsFuzzySearch)
                    {

                        var keywords = c.SearchPhrase.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries);
                        //var keywords = Regex.Split(c.SearchPhrase, @"\s+");
                        var searchPhrase = string.Empty;
                        searchPhrase = keywords.Aggregate(
                            searchPhrase,
                            (current, keyword) => current + String.Format("{0}~{1}", keyword.Replace("~", ""), c.FuzzyMinSimilarity));

                        var parser = new QueryParser(u.Version.LUCENE_30, "__content", analyzer)
                                         {
                                             DefaultOperator =
                                                 QueryParser
                                                 .Operator.AND
                                         };

                        var searchQuery = parser.Parse(searchPhrase);
                        query.Add(searchQuery, Occur.MUST);
                    }
                    else
                    {
                        var parser = new QueryParser(u.Version.LUCENE_30, "__content", analyzer)
                                         {
                                             DefaultOperator =
                                                 QueryParser
                                                 .Operator.AND
                                         };
                        var searchQuery = parser.Parse(c.SearchPhrase);
                        query.Add(searchQuery, Occur.MUST);
                    }
                }
            }
            else if (criteria is OrderSearchCriteria)
            {
                var c = criteria as OrderSearchCriteria;

                if (!String.IsNullOrEmpty(c.CustomerId))
                {
                    AddQuery("customerid", query, c.CustomerId);
                }
            }

            return builder;
        }
开发者ID:rdi-drew,项目名称:vc-community,代码行数:91,代码来源:LuceneSearchQueryBuilder.cs


示例20: SearchForUser

 /// <summary>
 /// Search users from repository according searchCriteria
 /// </summary>
 /// <param name="searchCriteria"> interface search criterias</param>
 public IEnumerable<int> SearchForUser(ISearchCriteria searchCriteria)
 {
     if (searchCriteria == null)
         throw new ArgumentNullException();
     return searchCriteria.Search(_users);
 }
开发者ID:RomanMakarov1002,项目名称:EPAM.RD.2016S.Makarau,代码行数:10,代码来源:MemoryRepository.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ISearchResponse类代码示例发布时间:2022-05-24
下一篇:
C# ISearchContext类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap