本文整理汇总了C#中CombinedQuery类的典型用法代码示例。如果您正苦于以下问题:C# CombinedQuery类的具体用法?C# CombinedQuery怎么用?C# CombinedQuery使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CombinedQuery类属于命名空间,在下文中一共展示了CombinedQuery类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ContainsItemsByFields
//public virtual List<SitecoreItem> GetRelatedItemsByField(FieldSearchParam param)
//{
// //string relatedIds, string templateIds, string fieldName, bool partial
// var globalQuery = new CombinedQuery();
// ApplyTemplateFilter(globalQuery, param.TemplateIds);
// var translator = new QueryTranslator(Index);
// var booleanQuery = translator.ConvertCombinedQuery(globalQuery);
// AddPartialFieldValueClause(booleanQuery, param.FieldName, param.RelatedIds);
// return RunQuery(booleanQuery, param.ShowAllVersions);
//}
public virtual bool ContainsItemsByFields(string ids, string fieldName, string fieldValue)
{
var globalQuery = new CombinedQuery();
ApplyIdFilter(globalQuery, BuiltinFields.ID, ids);
AddFieldValueClause(globalQuery, fieldName, fieldValue, QueryOccurance.Must);
return RunQuery(globalQuery).Count > 0;
}
示例2: AddFieldValueClause
internal static void AddFieldValueClause(CombinedQuery query, string fieldName, string fieldValue, QueryOccurance occurance)
{
if (fieldName.IsNullOrEmpty() || fieldValue.IsNullOrEmpty())
{
return;
}
fieldValue = IdHelper.ProcessGUIDs(fieldValue);
query.Add(new FieldQuery(fieldName, fieldValue), occurance);
}
示例3: ConvertCombinedQuery
public virtual BooleanQuery ConvertCombinedQuery(CombinedQuery query)
{
var booleanQuery = new BooleanQuery();
foreach (var clause in query.Clauses)
{
this.TranslateCombinedQuery(clause, booleanQuery);
}
return booleanQuery;
}
示例4: CreateQuery
private QueryBase CreateQuery(Database database)
{
var query = new CombinedQuery();
var databaseQuery = new FieldQuery(BuiltinFields.Database, database.Name);
var languageQuery = new FieldQuery(BuiltinFields.Language, Context.Language.Name);
var templateQuery = new FieldQuery(BuiltinFields.Template, ShortID.Encode(RewriteReportItem.TemplateId));
query.Add(databaseQuery, QueryOccurance.Must);
query.Add(languageQuery, QueryOccurance.Must);
query.Add(templateQuery, QueryOccurance.Must);
return query;
}
示例5: ApplyRefinements
protected CombinedQuery ApplyRefinements(IEnumerable<Refinement> refinements, QueryOccurance occurance)
{
if (refinements.Count() <= 0) return new CombinedQuery();
var innerQuery = new CombinedQuery();
foreach (var refinement in refinements)
{
AddFieldValueClause(innerQuery, refinement.Name, refinement.Value, occurance);
}
return innerQuery;
}
示例6: ConvertCombinedQuery
public virtual BooleanQuery ConvertCombinedQuery(CombinedQuery query)
{
var booleanQuery = new BooleanQuery();
foreach (var clause in query.Clauses)
{
var translatedQuery = Translate(clause.Query);
if (translatedQuery != null)
{
booleanQuery.Add(translatedQuery, GetOccur(clause.Occurance));
}
}
return booleanQuery;
}
示例7: ProcessQuery
public virtual BooleanQuery ProcessQuery(QueryOccurance occurance, Index index)
{
var innerQuery = new CombinedQuery();
ApplyFullTextClause(innerQuery, FullTextQuery, occurance);
ApplyRelationFilter(innerQuery, RelatedIds, occurance);
ApplyTemplateFilter(innerQuery, TemplateIds, occurance);
ApplyLocationFilter(innerQuery, LocationIds, occurance);
AddFieldValueClause(innerQuery, BuiltinFields.Database, Database, occurance);
if (innerQuery.Clauses.Count < 1)
return null;
var translator = new QueryTranslator(index);
var booleanQuery = translator.ConvertCombinedQuery(innerQuery);
ApplyLanguageClause(booleanQuery, Language, translator.GetOccur(occurance));
return booleanQuery;
}
示例8: FieldSearch
public SitecoreSearchResultCollection FieldSearch(QueryInfo[] qis, int maxResults)
{
HighResTimer timer = new HighResTimer(true);
var combinedQuery = new CombinedQuery();
foreach (var qi in qis)
{
var q = GetQuery(qi);
if (q != null)
combinedQuery.Add(q, qi.SitecoreSearchQueryOccurance);
}
SearchResultCollection results = null;
if (combinedQuery.Clauses.Count > 0)
results = GetSearchHits(combinedQuery, maxResults);
return results != null
? new SitecoreSearchResultCollection(results, timer.Elapsed())
: null;
}
示例9: ApplyLocationFilter
protected void ApplyLocationFilter(CombinedQuery query, string locationIds, QueryOccurance occurance)
{
ApplyIdFilter(query, BuiltinFields.Path, locationIds, occurance);
}
示例10: ApplyIdFilter
protected void ApplyIdFilter(CombinedQuery query, string fieldName, string filter, QueryOccurance occurance)
{
if (String.IsNullOrEmpty(fieldName) || String.IsNullOrEmpty(filter)) return;
var filterQuery = new CombinedQuery();
var values = IdHelper.ParseId(filter);
foreach (var value in values.Where(ID.IsID))
{
AddFieldValueClause(filterQuery, fieldName, value, QueryOccurance.Should);
}
query.Add(filterQuery, occurance);
}
示例11: GetItemsInRange
public virtual List<SitecoreItem> GetItemsInRange(DateRangeSearchParam param)
{
var globalQuery = new CombinedQuery();
ApplyLanguageClause(globalQuery, param.Language);
ApplyTemplateFilter(globalQuery, param.TemplateIds);
ApplyLocationFilter(globalQuery, param.LocationIds);
ApplyFullTextClause(globalQuery, param.FullTextQuery);
ApplyRelationFilter(globalQuery, param.RelatedIds);
var translator = new QueryTranslator(Index);
var booleanQuery = translator.ConvertCombinedQuery(globalQuery);
var innerOccurance = translator.GetOccur(param.Occurance);
ApplyDateRangeSearchParam(booleanQuery, param, innerOccurance);
return RunQuery(booleanQuery, param.ShowAllVersions);
}
示例12: ContructQuery
public static BooleanQuery ContructQuery(DateRangeSearchParam param)
{
var indexName = BucketManager.GetContextIndex(Context.ContentDatabase.GetItem(param.LocationIds));
if (indexName.EndsWith("_remote"))
{
Index = RemoteSearchManager.GetIndex(indexName) as RemoteIndex;
}
else if (indexName.EndsWith("_inmemory"))
{
Index = InMemorySearchManager.GetIndex(indexName) as InMemoryIndex;
}
else
{
Index = SearchManager.GetIndex(indexName) as Index;
}
if (Index.IsNotNull())
{
var globalQuery = new CombinedQuery();
var fullTextQuery = param.FullTextQuery; // .TrimStart('*').TrimEnd('*') + "*";
SearcherMethods.ApplyLanguageClause(globalQuery, param.Language);
if (!string.IsNullOrWhiteSpace(fullTextQuery))
{
if (!fullTextQuery.StartsWith("*"))
{
SearcherMethods.ApplyFullTextClause(globalQuery, fullTextQuery, indexName);
}
}
SearcherMethods.ApplyRelationFilter(globalQuery, param.RelatedIds);
SearcherMethods.ApplyTemplateFilter(globalQuery, param.TemplateIds);
SearcherMethods.ApplyTemplateNotFilter(globalQuery);
SearcherMethods.ApplyIDFilter(globalQuery, param.ID);
SearcherMethods.ApplyLocationFilter(globalQuery, param.LocationIds);
SearcherMethods.ApplyRefinements(globalQuery, param.Refinements, QueryOccurance.Should);
SearcherMethods.ApplyLatestVersion(globalQuery);
if (Config.ExcludeContextItemFromResult)
{
SearcherMethods.ApplyContextItemRemoval(globalQuery, param.LocationIds);
}
var translator = new QueryTranslator(Index);
var booleanQuery = translator.ConvertCombinedQuery(globalQuery);
var innerOccurance = translator.GetOccur(param.Occurance);
if (!string.IsNullOrWhiteSpace(fullTextQuery))
{
if (fullTextQuery.StartsWith("*"))
{
SearcherMethods.ApplyFullTextClause(booleanQuery, fullTextQuery, indexName);
}
}
SearcherMethods.ApplyAuthor(booleanQuery, param.Author);
SearcherMethods.ApplyDateRangeSearchParam(booleanQuery, param, innerOccurance);
if (Config.EnableBucketDebug || Constants.EnableTemporaryBucketDebug)
{
Log.Info("Search Clauses Number: " + booleanQuery.Clauses().Count, booleanQuery);
}
return booleanQuery;
}
return null;
}
示例13: GetItems
internal virtual KeyValuePair<int, List<SitecoreItem>> GetItems(DateRangeSearchParam param)
{
var db = Context.ContentDatabase ?? Sitecore.Context.Database;
if (db != null)
{
var indexName = Util.Constants.Index.Name;
var item = db.GetItem(param.LocationIds);
indexName = BucketManager.GetContextIndex(item.IsNotNull() ? item : db.GetItem(Sitecore.ItemIDs.RootID));
if (indexName.EndsWith("_remote"))
{
Index = RemoteSearchManager.GetIndex(indexName) as RemoteIndex;
}
else if (indexName.EndsWith("_inmemory"))
{
Index = InMemorySearchManager.GetIndex(indexName) as InMemoryIndex;
}
else
{
Index = SearchManager.GetIndex(indexName) as Index;
}
if (Index.IsNotNull())
{
var globalQuery = new CombinedQuery();
SearcherMethods.ApplyLanguageClause(globalQuery, param.Language);
if (!string.IsNullOrWhiteSpace(param.FullTextQuery))
{
if (!param.FullTextQuery.StartsWith("*"))
{
if (param.FullTextQuery != "*All*" && param.FullTextQuery != "*" && param.FullTextQuery != "**")
{
SearcherMethods.ApplyFullTextClause(globalQuery, param.FullTextQuery, indexName);
}
}
}
SearcherMethods.ApplyRelationFilter(globalQuery, param.RelatedIds);
SearcherMethods.ApplyTemplateFilter(globalQuery, param.TemplateIds);
SearcherMethods.ApplyTemplateNotFilter(globalQuery);
SearcherMethods.ApplyIDFilter(globalQuery, param.ID);
if (param.LocationIds.Contains("|"))
{
SearcherMethods.ApplyCombinedLocationFilter(globalQuery, param.LocationIds);
}
else
{
SearcherMethods.ApplyLocationFilter(globalQuery, param.LocationIds);
}
if (!param.Refinements.ContainsKey("__workflow state")) //Hack!!!!!
{
SearcherMethods.ApplyRefinements(globalQuery, param.Refinements, QueryOccurance.Should);
}
SearcherMethods.ApplyLatestVersion(globalQuery);
if (Config.ExcludeContextItemFromResult)
{
SearcherMethods.ApplyContextItemRemoval(globalQuery, param.LocationIds);
}
SearcherMethods.ApplyNameFilter(globalQuery, param.ItemName);
var translator = new QueryTranslator(Index);
var booleanQuery = translator.ConvertCombinedQuery(globalQuery);
var innerOccurance = translator.GetOccur(param.Occurance);
if (!string.IsNullOrWhiteSpace(param.FullTextQuery))
{
if (param.FullTextQuery.StartsWith("*"))
{
if (param.FullTextQuery != "*All*" && param.FullTextQuery != "*" && param.FullTextQuery != "**")
{
SearcherMethods.ApplyFullTextClause(booleanQuery, param.FullTextQuery, indexName);
}
}
}
SearcherMethods.ApplyAuthor(booleanQuery, param.Author);
SearcherMethods.ApplyDateRangeSearchParam(booleanQuery, param, innerOccurance);
if (param.Refinements.ContainsKey("__workflow state"))
{
SearcherMethods.AddFieldValueClause(booleanQuery, "__workflow state", param.Refinements["__workflow state"], QueryOccurance.Should);
}
if (Config.EnableBucketDebug || Constants.EnableTemporaryBucketDebug)
{
Log.Info("Search Clauses Number: " + booleanQuery.Clauses().Count, this);
}
if (!param.SortByField.IsNullOrEmpty())
{
return this.RunQuery(booleanQuery, param.PageSize, param.PageNumber, param.SortByField, param.SortDirection);
}
return param.PageNumber != 0 ? this.RunQuery(booleanQuery, param.PageSize, param.PageNumber) : this.RunQuery(booleanQuery, 20, 0);
}
}
return new KeyValuePair<int, List<SitecoreItem>>();
}
示例14: GetItems
//public virtual List<SitecoreItem> GetItemsViaTermQuery(string fieldName, string fieldValue)
//{
// var query = new TermQuery(new Term(fieldName, fieldValue));
// return RunQuery(query, false);
//}
//public virtual List<SitecoreItem> GetItemsViaFieldQuery(string fieldName, string fieldValue)
//{
// var query = new FieldQuery(fieldName, fieldValue);
// return RunQuery(query, false);
//}
public virtual List<SitecoreItem> GetItems(SearchParam param)
{
var globalQuery = new CombinedQuery();
ApplyLanguageClause(globalQuery, param.Language);
if (!String.IsNullOrWhiteSpace(param.FullTextQuery))
{
ApplyFullTextClause(globalQuery, param.FullTextQuery);
}
ApplyRelationFilter(globalQuery, param.RelatedIds);
ApplyTemplateFilter(globalQuery, param.TemplateIds);
ApplyLocationFilter(globalQuery, param.LocationIds);
return RunQuery(globalQuery, param.ShowAllVersions);
}
示例15: GetQuery
private QueryBase GetQuery()
{
QueryBase base2 = null;
NameValueCollection fieldValues = GetFieldValues();
string str = StringUtil.GetString(new string[] { Context.ClientPage.ClientRequest.Form["TreeSearch"] });
if (str == "Search")
{
str = string.Empty;
}
str = str.Trim();
if (!string.IsNullOrEmpty(str))
{
base2 = new FullTextQuery(str);
}
if (fieldValues.Count <= 0)
{
return base2;
}
CombinedQuery query = new CombinedQuery();
foreach (string str2 in fieldValues.AllKeys)
{
string fieldValue = fieldValues[str2];
if (fieldValue.Length > 0)
{
query.Add(new FieldQuery(str2.ToLowerInvariant(), fieldValue), QueryOccurance.Should);
}
}
return query;
}