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


C# ISearchCriteria.GroupedOr方法代码示例

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


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

示例1: 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

示例2: 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

示例3: TextSearchAllFields

        internal ISearchResults TextSearchAllFields(string searchText, bool useWildcards, ISearchCriteria sc)
        {
            var splitSearch = searchText.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

            if (useWildcards)
            {
                sc = sc.GroupedOr(GetSearchFields(),
                    splitSearch.Select(x =>
                        new ExamineValue(Examineness.ComplexWildcard, x.MultipleCharacterWildcard().Value)).Cast<IExamineValue>().ToArray()
                    ).Compile();
            }
            else
            {
                sc = sc.GroupedOr(GetSearchFields(), splitSearch).Compile();
            }

            return Search(sc);
        }
开发者ID:jclementson,项目名称:Examine,代码行数:18,代码来源:BaseLuceneSearcher.cs


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