本文整理汇总了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;
}
示例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;
}
示例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);
}