private JsonResult GetJsonResponse() { Guard.IsNotNull(this.DataSource, "DataSource"); IQueryable dataSource = this.DataSource as IQueryable; Guard.IsNotNull(dataSource, "DataSource", "should implement the IQueryable interface."); Guard.IsNotNullOrEmpty(this.DataField, "DataField", "should be set to the datafield (column) of the datasource to search in."); SearchOperation isEqualTo = SearchOperation.IsEqualTo; if (this.AutoCompleteMode == Trirand.Web.Mvc.AutoCompleteMode.BeginsWith) { isEqualTo = SearchOperation.BeginsWith; } else { isEqualTo = SearchOperation.Contains; } string str = HttpContext.Current.Request.QueryString["term"]; if (!string.IsNullOrEmpty(str)) { Util.SearchArguments args = new Util.SearchArguments(); args.SearchColumn = this.DataField; args.SearchOperation = isEqualTo; args.SearchString = str; dataSource = dataSource.Where(Util.ConstructLinqFilterExpression(this, args), new object[0]); } JsonResult result2 = new JsonResult(); result2.JsonRequestBehavior = JsonRequestBehavior.AllowGet; result2.Data = dataSource.ToListOfString(this); return(result2); }
public JQGridSearchEventArgs(string searchColumn, string searchString, SearchOperation searchOperation) : this() { this._searchColumn = searchColumn; this._searchString = searchString; this._searchOperation = searchOperation; }
public SearchResultContext <SearchModelBase> Search() { var requester = new SearchOperation(); var queryContext = new QueryContext { Client = Configuration.ClientGuid.ToString() }; for (var a = 0; a < SearchClients.Count; a++) { SearchClients[a].Query.QueryId = a + 1; QueryIdToClient.Add(SearchClients[a].Query.QueryId, SearchClients[a]); queryContext.Querys.Add(SearchClients[a].Query); } var jsonData = requester.PreformSearch(JsonConvert.SerializeObject(queryContext, Formatting.None), Configuration); var result = JsonConvert.DeserializeObject <SearchResultContext <SearchModelBase> >(jsonData, new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.All }); foreach (var searchResult in result.SearchResults) { var client = QueryIdToClient[searchResult.QueryId]; var fcm = new FacetContextMerger <SearchModelBase>(); var genericType = client.GetType().IsGenericType ? client.GetType().GetGenericArguments()[0] : null; fcm.MergeFacets(result.CrawlStamp, searchResult.Facets, client.IncEmptyFacets, client.Lang, genericType); } return(result); }
private static Expression MakeComparison(Expression left, SearchOperation searchOperation, string value) { switch (searchOperation) { case SearchOperation.Equal: return(MakeBinary(ExpressionType.Equal, left, value)); case SearchOperation.NotEqual: return(MakeBinary(ExpressionType.NotEqual, left, value)); case SearchOperation.GreatherThen: return(MakeBinary(ExpressionType.GreaterThan, left, value)); case SearchOperation.GreatherThenOrEqualTo: return(MakeBinary(ExpressionType.GreaterThanOrEqual, left, value)); case SearchOperation.LessThan: return(MakeBinary(ExpressionType.LessThan, left, value)); case SearchOperation.LessThanOrEqualTo: return(MakeBinary(ExpressionType.LessThanOrEqual, left, value)); case SearchOperation.Contains: case SearchOperation.StartsWith: case SearchOperation.EndsWith: return(Expression.Call(MakeString(left), searchOperation.ToString(), Type.EmptyTypes, Expression.Constant(value, typeof(string)))); default: throw new NotSupportedException($"This search operation ({searchOperation}) does not extists."); } }
private JsonResult GetJsonResponse() { Guard.IsNotNull(this.DataSource, "DataSource"); IQueryable queryable = this.DataSource as IQueryable; Guard.IsNotNull(queryable, "DataSource", "should implement the IQueryable interface."); Guard.IsNotNullOrEmpty(this.DataField, "DataField", "should be set to the datafield (column) of the datasource to search in."); SearchOperation searchOperation = SearchOperation.IsEqualTo; if (this.AutoCompleteMode == AutoCompleteMode.BeginsWith) { searchOperation = SearchOperation.BeginsWith; } else { searchOperation = SearchOperation.Contains; } string text = HttpContext.Current.Request.QueryString["term"]; if (!string.IsNullOrEmpty(text)) { queryable = queryable.Where(Util.ConstructLinqFilterExpression(this, new Util.SearchArguments { SearchColumn = this.DataField, SearchOperation = searchOperation, SearchString = text }), new object[0]); } return(new JsonResult { JsonRequestBehavior = JsonRequestBehavior.AllowGet, Data = queryable.ToListOfString(this) }); }
public GridSearch(String searchColumn, String searchString, SearchOperation searchOperation) : this() { this.searchColumn = searchColumn; this.searchString = searchString; this.searchOperation = searchOperation; }
public ActionResult Profile() { string UserName = (string)Session["UserName"]; if (UserName == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SearchOperation searchOperation = new SearchOperation(); Users user = searchOperation.GetUser(UserName); Student student = searchOperation.GetStudent(user.UserId); Address address = searchOperation.GetAddress(student.StudentId); District parDistrict = searchOperation.GetDistrict((int)address.P_DistrictId); District TemDistrict = searchOperation.GetDistrict((int)address.T_DistrictId); DepartmentInfo departmentInfo = searchOperation.GetDepartmentInfo(student.StudentId); Department department = searchOperation.GetDepartment((int)departmentInfo.DepartmentId); Room room = searchOperation.GetRoom((int)student.RoomId); UserProfileModel userProfileModel = new UserProfileModel(); userProfileModel.StudentName = student.StudentName; userProfileModel.FatherName = student.FatherName; userProfileModel.MotherName = student.MotherName; userProfileModel.MobileNumber = student.MobileNumber; userProfileModel.ParmanentDistrict = parDistrict.DistrictName; userProfileModel.ParmanentPostOfiice = address.P_PostOffice; userProfileModel.ParmanentVillage = address.P_VillageName; userProfileModel.TemporaryDistrict = TemDistrict.DistrictName; userProfileModel.TemporaryPostOfiice = address.T_PostOffice; userProfileModel.TemporaryVillage = address.T_VillageName; userProfileModel.DepartmentName = department.DeptName; userProfileModel.Session = departmentInfo.Session; userProfileModel.Cgpa = departmentInfo.Cgpa; userProfileModel.RoomNumber = (int)room.RoomNumber; return(View(userProfileModel)); }
/// <summary> /// Stores the aws params in dictionary for url signing. For "search all" operation. /// </summary> /// <returns>The in dictionary.</returns> /// <param name="searchText">Search text.</param> /// <param name="page">Page.</param> private static IDictionary <string, string> StoreInDictionary(string searchText, string page) { SearchOperation searchOp = new SearchOperation(); searchOp.PresetOperation(searchText, page); return(searchOp.StoreInDictionary); }
private void OperationElements <T>(List <T> elements, SearchOperation operationType) { var indexName = typeof(T).Equals(typeof(EntitySearch)) ? _entityIndex : _commentIndex; var indexClient = _search.Indexes.GetClient(indexName); var actions = elements.Select(o => operationType == SearchOperation.Add ? IndexAction.Upload(o) : IndexAction.Delete(o)); var batch = IndexBatch.New(actions); indexClient.Documents.Index(batch); }
internal string GetFilterExpression(SearchOperation searchOperation, string dataField, string searchString, Type dataType) { searchString = searchString.Replace("'", "''"); string format = this.ExpressionNeedsQuotes(dataType) ? "[{0}] {1} '{2}'" : "[{0}] {1} {2}"; string format2 = "[{0}] {1} ({2})"; string format3 = "[{0}] LIKE '{1}'"; string format4 = "[{0}] NOT LIKE '{1}'"; switch (searchOperation) { case SearchOperation.IsEqualTo: return(string.Format(format, dataField, "=", searchString)); case SearchOperation.IsNotEqualTo: return(string.Format(format, dataField, "<>", searchString)); case SearchOperation.IsLessThan: return(string.Format(format, dataField, "<", searchString)); case SearchOperation.IsLessOrEqualTo: return(string.Format(format, dataField, "<=", searchString)); case SearchOperation.IsGreaterThan: return(string.Format(format, dataField, ">", searchString)); case SearchOperation.IsGreaterOrEqualTo: return(string.Format(format, dataField, ">=", searchString)); case SearchOperation.IsIn: return(string.Format(format2, dataField, "in", searchString)); case SearchOperation.IsNotIn: return(string.Format(format2, dataField, "not in", searchString)); case SearchOperation.BeginsWith: return(string.Format(format3, dataField, searchString + "%")); case SearchOperation.DoesNotBeginWith: return(string.Format(format4, dataField, searchString + "%")); case SearchOperation.EndsWith: return(string.Format(format3, dataField, "%" + searchString)); case SearchOperation.DoesNotEndWith: return(string.Format(format4, dataField, "%" + searchString)); case SearchOperation.Contains: return(string.Format(format3, dataField, "%" + searchString + "%")); case SearchOperation.DoesNotContain: return(string.Format(format4, dataField, "%" + searchString + "%")); default: throw new Exception("Invalid search operation."); } }
public string GetStringFromSearchOperation(SearchOperation operation) { switch (operation) { case SearchOperation.IsEqualTo: return("eq"); case SearchOperation.IsNotEqualTo: return("ne"); case SearchOperation.IsLessThan: return("lt"); case SearchOperation.IsLessOrEqualTo: return("le"); case SearchOperation.IsGreaterThan: return("gt"); case SearchOperation.IsGreaterOrEqualTo: return("ge"); case SearchOperation.IsIn: return("in"); case SearchOperation.IsNotIn: return("ni"); case SearchOperation.BeginsWith: return("bw"); case SearchOperation.DoesNotBeginWith: return("bn"); case SearchOperation.EndsWith: return("ew"); case SearchOperation.DoesNotEndWith: return("en"); case SearchOperation.Contains: return("cn"); case SearchOperation.DoesNotContain: return("nc"); default: return("eq"); } }
/// <summary> /// Añade o elimina items dentro de azure search. /// </summary> /// <typeparam name="T">El tipo solo puede ser una entidad soportada dentro de azure search, se validará que cumpla</typeparam> /// <param name="elements">elementos a guardar dentro del search</param> /// <param name="operationType">Tipo de operación Añadir o borrar</param> private void OperationElements <T>(List <T> elements, SearchOperation operationType) { // validar que sea un elemento de tipo search. var indexName = Index; // realiza la acción segun el argumento var actions = elements.Select(o => operationType == SearchOperation.Add ? IndexDocumentsAction.Upload(o) : IndexDocumentsAction.Delete(o)).ToArray(); // preparando la ejecución var batch = IndexDocumentsBatch.Create(actions); // ejecución. _search.IndexDocuments(batch); }
public SearchResult <T> Search() { var requester = new SearchOperation(); var jsonSerializerSettings = new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.All }; var jsonData = requester.PreformSearch(JsonConvert.SerializeObject(ConvertExpression(), Formatting.None), Configuration); var result = JsonConvert.DeserializeObject <SearchResultContext <T> >(jsonData, jsonSerializerSettings); var fcm = new FacetContextMerger <T>(); fcm.MergeFacets(result.CrawlStamp, result.SearchResults[0].Facets, ((ISearchClient)this).IncEmptyFacets, ((ISearchClient)this).Lang); return(result.SearchResults[0]); }
internal string GetLinqFilterExpression(SearchOperation searchOperation, string dataField, string searchString, Type dataType) { string format = this.ExpressionNeedsQuotes(dataType) ? "{0} {1} \"{2}\"" : "{0} {1} {2}"; if (dataType == typeof(DateTime)) { format = "{0} {1} DateTime.Parse(\"{2}\")"; } switch (searchOperation) { case SearchOperation.IsEqualTo: return(string.Format(format, dataField, "=", searchString)); case SearchOperation.IsNotEqualTo: return(string.Format(format, dataField, "<>", searchString)); case SearchOperation.IsLessThan: return(string.Format(format, dataField, "<", searchString)); case SearchOperation.IsLessOrEqualTo: return(string.Format(format, dataField, "<=", searchString)); case SearchOperation.IsGreaterThan: return(string.Format(format, dataField, ">", searchString)); case SearchOperation.IsGreaterOrEqualTo: return(string.Format(format, dataField, ">=", searchString)); case SearchOperation.BeginsWith: return(string.Format("{0}.BeginsWith(\"{1}\")", dataField, searchString)); case SearchOperation.DoesNotBeginWith: return(string.Format("!{0}.BeginsWith(\"{1}\")", dataField, searchString)); case SearchOperation.EndsWith: return(string.Format("{0}.EndsWith(\"{1}\")", dataField, searchString)); case SearchOperation.DoesNotEndWith: return(string.Format("!{0}.EndsWith(\"{1}\")", dataField, searchString)); case SearchOperation.Contains: return(string.Format("{0}.Contains(\"{1}\")", dataField, searchString)); case SearchOperation.DoesNotContain: return(string.Format("!{0}.Contains(\"{1}\")", dataField, searchString)); } throw new Exception("Invalid search operation."); }
public virtual iFolderSet GetiFoldersByName(SearchOperation operation, string pattern, int index, int max) { iFolderSet result = null; try { Authorize(); result = iFolder.GetiFoldersByMember(GetUserID(), MemberRole.Any, operation, pattern, index, max, GetAccessID()); } catch (Exception e) { SmartException.Throw(e); } return(result); }
private SearchOperationViewModel convertSearchOperationTypes(SearchOperation searchOperation) { SearchOperationViewModel soVM = new SearchOperationViewModel(SearchOperationViewModel.Contains); switch (searchOperation) { case SearchOperation.None: soVM = new SearchOperationViewModel(SearchOperationViewModel.None); break; case SearchOperation.Equal: soVM = new SearchOperationViewModel(SearchOperationViewModel.Equal); break; case SearchOperation.NotEquals: soVM = new SearchOperationViewModel(SearchOperationViewModel.NotEquals); break; case SearchOperation.LessThan: soVM = new SearchOperationViewModel(SearchOperationViewModel.LessThan); break; case SearchOperation.LessThanOrEqual: soVM = new SearchOperationViewModel(SearchOperationViewModel.LessThanOrEqual); break; case SearchOperation.GreaterThanOrEqual: soVM = new SearchOperationViewModel(SearchOperationViewModel.GreaterThanOrEqual); break; case SearchOperation.BeginsWith: soVM = new SearchOperationViewModel(SearchOperationViewModel.BeginsWith); break; case SearchOperation.DoesNotBeginWith: soVM = new SearchOperationViewModel(SearchOperationViewModel.DoesNotBeginWith); break; case SearchOperation.Contains: soVM = new SearchOperationViewModel(SearchOperationViewModel.Contains); break; case SearchOperation.DoesNotContain: soVM = new SearchOperationViewModel(SearchOperationViewModel.DoesNotContain); break; case SearchOperation.EndsWith: soVM = new SearchOperationViewModel(SearchOperationViewModel.EndsWith); break; case SearchOperation.DoesNotEndWith: soVM = new SearchOperationViewModel(SearchOperationViewModel.DoesNotEndWith); break; case SearchOperation.IsNull: soVM = new SearchOperationViewModel(SearchOperationViewModel.IsNull); break; case SearchOperation.IsNotNull: soVM = new SearchOperationViewModel(SearchOperationViewModel.IsNotNull); break; case SearchOperation.DateOnly: soVM = new SearchOperationViewModel(SearchOperationViewModel.DateOnly); break; case SearchOperation.DateAndTime: soVM = new SearchOperationViewModel(SearchOperationViewModel.DateAndTime); break; default: soVM = new SearchOperationViewModel(SearchOperationViewModel.Contains); break; } return(soVM); }
private SearchOperation convertSearchOperationTypes(SearchOperationViewModel searchOperationViewModel) { SearchOperation so = SearchOperation.Equal; switch (searchOperationViewModel.Value) { case SearchOperationViewModel.None: so = SearchOperation.None; break; case SearchOperationViewModel.Equal: so = SearchOperation.Equal; break; case SearchOperationViewModel.NotEquals: so = SearchOperation.NotEquals; break; case SearchOperationViewModel.LessThan: so = SearchOperation.LessThan; break; case SearchOperationViewModel.LessThanOrEqual: so = SearchOperation.LessThanOrEqual; break; case SearchOperationViewModel.GreaterThanOrEqual: so = SearchOperation.GreaterThanOrEqual; break; case SearchOperationViewModel.BeginsWith: so = SearchOperation.BeginsWith; break; case SearchOperationViewModel.DoesNotBeginWith: so = SearchOperation.DoesNotBeginWith; break; case SearchOperationViewModel.Contains: so = SearchOperation.Contains; break; case SearchOperationViewModel.DoesNotContain: so = SearchOperation.DoesNotContain; break; case SearchOperationViewModel.EndsWith: so = SearchOperation.EndsWith; break; case SearchOperationViewModel.DoesNotEndWith: so = SearchOperation.DoesNotEndWith; break; case SearchOperationViewModel.IsNull: so = SearchOperation.IsNull; break; case SearchOperationViewModel.IsNotNull: so = SearchOperation.IsNotNull; break; case SearchOperationViewModel.DateOnly: so = SearchOperation.DateOnly; break; case SearchOperationViewModel.DateAndTime: so = SearchOperation.DateAndTime; break; default: so = SearchOperation.Contains; break; } return(so); }
public static ArrayList getAllDomainUsers(Domain domain, string username) { SearchProperty searchProperty = SearchProperty.UserName; SearchOperation searchOperation = SearchOperation.BeginsWith; string pattern = "*"; Simias.Storage.SearchPropertyList SearchPrpList = new Simias.Storage.SearchPropertyList(); //SearchPrpList.Add(searchProperty, pattern, searchOperation); SearchPrpList.Add("DN", "*", SearchOp.Exists); ICSList searchList = domain.Search(SearchPrpList); ArrayList list = new ArrayList(); Member member = null; Console.WriteLine("Total No Of Users in Domain: " + searchList.Count); foreach (ShallowNode sn in searchList) { try { if (sn.IsBaseType(NodeTypes.MemberType)) { member = new Member(domain, sn); Member mem = domain.GetMemberByID(member.UserID); //add only those members to list whose home server is current server if (mem.HomeServer != null) { if (String.Equals(mem.Name, username) && mem.HomeServer.UserID == HostNode.GetLocalHost().UserID) { list.Add(mem); break; } } } } catch (Exception ex) { Console.WriteLine("Error: " + ex.Message); Console.WriteLine("Error Trace: " + ex.StackTrace); } } Console.WriteLine("Total No Of Users for whom Home Server is current server: " + list.Count); return(list); }
static void Main(string[] args) { string fileName = @"c:\WordSearchText.csv"; if (args.Length > 0) { fileName = args[0]; } SearchOperation searchOperation = new SearchOperation(fileName); if (searchOperation.Error == -1) { } List <SearchEngine> searchEngines = new List <SearchEngine>(); searchEngines.Add(new SearchForward(searchOperation.rowcnt, searchOperation.cols)); searchEngines.Add(new SearchBack(searchOperation.rowcnt, searchOperation.cols)); searchEngines.Add(new SearchDown(searchOperation.rowcnt, searchOperation.cols)); searchEngines.Add(new SearchUp(searchOperation.rowcnt, searchOperation.cols)); searchEngines.Add(new SearchDiagUpRightToLeft(searchOperation.rowcnt, searchOperation.cols)); searchEngines.Add(new SearchDiagUpLeftToRight(searchOperation.rowcnt, searchOperation.cols)); searchEngines.Add(new SearchDiagDownRightToLeft(searchOperation.rowcnt, searchOperation.cols)); searchEngines.Add(new SearchDiagDownLeftToRight(searchOperation.rowcnt, searchOperation.cols)); foreach (string value in searchOperation.SearchValuesArray) { bool found = false; for (int i = 0; i != -1 && !found; ++i) { i = SearchEngine.GetIndex(i, value, searchOperation.stringSearchGrid); if (i == -1) { break; } else { found = SearchEngine.RunEngines(searchEngines, i, value, searchOperation.stringSearchGrid); } } } }
internal string GetFilterExpression(SearchOperation searchOperation, string dataField, string searchString, Type dataType) { searchString = searchString.Replace("'", "''"); string format = this.ExpressionNeedsQuotes(dataType) ? "[{0}] {1} '{2}'" : "[{0}] {1} {2}"; string format2 = "[{0}] {1} ({2})"; string format3 = "[{0}] LIKE '{1}'"; string format4 = "[{0}] NOT LIKE '{1}'"; switch (searchOperation) { case SearchOperation.IsEqualTo: return string.Format(format, dataField, "=", searchString); case SearchOperation.IsNotEqualTo: return string.Format(format, dataField, "<>", searchString); case SearchOperation.IsLessThan: return string.Format(format, dataField, "<", searchString); case SearchOperation.IsLessOrEqualTo: return string.Format(format, dataField, "<=", searchString); case SearchOperation.IsGreaterThan: return string.Format(format, dataField, ">", searchString); case SearchOperation.IsGreaterOrEqualTo: return string.Format(format, dataField, ">=", searchString); case SearchOperation.IsIn: return string.Format(format2, dataField, "in", searchString); case SearchOperation.IsNotIn: return string.Format(format2, dataField, "not in", searchString); case SearchOperation.BeginsWith: return string.Format(format3, dataField, searchString + "%"); case SearchOperation.DoesNotBeginWith: return string.Format(format4, dataField, searchString + "%"); case SearchOperation.EndsWith: return string.Format(format3, dataField, "%" + searchString); case SearchOperation.DoesNotEndWith: return string.Format(format4, dataField, "%" + searchString); case SearchOperation.Contains: return string.Format(format3, dataField, "%" + searchString + "%"); case SearchOperation.DoesNotContain: return string.Format(format4, dataField, "%" + searchString + "%"); default: throw new Exception("Invalid search operation."); } }
private string GetJsonResponse() { //IL_0072: Unknown result type (might be due to invalid IL or missing references) Guard.IsNotNull(DataSource, "DataSource"); IQueryable queryable = DataSource as IQueryable; Guard.IsNotNull(queryable, "DataSource", "should implement the IQueryable interface."); Guard.IsNotNullOrEmpty(DataField, "DataField", "should be set to the datafield (column) of the datasource to search in."); SearchOperation searchOperation = SearchOperation.IsEqualTo; searchOperation = ((AutoCompleteMode != 0) ? SearchOperation.Contains : SearchOperation.BeginsWith); string text = _httpContext.Request.Query["term"]; if (!string.IsNullOrEmpty(text)) { queryable = queryable.Where(Util.ConstructLinqFilterExpression(this, new Util.SearchArguments { SearchColumn = DataField, SearchOperation = searchOperation, SearchString = text })); } List <string> list = new List <string>(); List <Hashtable> list2 = Util.ToListOfHashtables(queryable); foreach (Hashtable item in list2) { if (item[DataField] != null) { list.Add(item[DataField] as string); } else { list.Add(string.Empty); } } return(JsonConvert.SerializeObject((object)list)); }
public static void AddSearchDropdown(CoreColumn column, List <SelectListItem> items, SearchOperation searchOperation = SearchOperation.IsEqualTo, bool needAllItem = true) { column.SearchToolBarOperation = searchOperation; column.SearchOptions = new List <SearchOperation> { searchOperation }; column.SearchType = SearchType.DropDown; var searchList = new List <SelectListItem>(); if (needAllItem) { searchList.Add(new SelectListItem { Text = "Все", Value = null }); } searchList.AddRange(items); column.ShowSearchOperators = false; column.SearchList = searchList; }
internal string GetLinqFilterExpression(SearchOperation searchOperation, string dataField, string searchString, Type dataType) { string format = this.ExpressionNeedsQuotes(dataType) ? "{0} {1} \"{2}\"" : "{0} {1} {2}"; if (dataType == typeof(DateTime)) { format = "{0} {1} DateTime.Parse(\"{2}\")"; } switch (searchOperation) { case SearchOperation.IsEqualTo: return string.Format(format, dataField, "=", searchString); case SearchOperation.IsNotEqualTo: return string.Format(format, dataField, "<>", searchString); case SearchOperation.IsLessThan: return string.Format(format, dataField, "<", searchString); case SearchOperation.IsLessOrEqualTo: return string.Format(format, dataField, "<=", searchString); case SearchOperation.IsGreaterThan: return string.Format(format, dataField, ">", searchString); case SearchOperation.IsGreaterOrEqualTo: return string.Format(format, dataField, ">=", searchString); case SearchOperation.BeginsWith: return string.Format("{0}.BeginsWith(\"{1}\")", dataField, searchString); case SearchOperation.DoesNotBeginWith: return string.Format("!{0}.BeginsWith(\"{1}\")", dataField, searchString); case SearchOperation.EndsWith: return string.Format("{0}.EndsWith(\"{1}\")", dataField, searchString); case SearchOperation.DoesNotEndWith: return string.Format("!{0}.EndsWith(\"{1}\")", dataField, searchString); case SearchOperation.Contains: return string.Format("{0}.Contains(\"{1}\")", dataField, searchString); case SearchOperation.DoesNotContain: return string.Format("!{0}.Contains(\"{1}\")", dataField, searchString); } throw new Exception("Invalid search operation."); }
public string GetStringFromSearchOperation(SearchOperation operation) { switch (operation) { case SearchOperation.IsEqualTo: return "eq"; case SearchOperation.IsNotEqualTo: return "ne"; case SearchOperation.IsLessThan: return "lt"; case SearchOperation.IsLessOrEqualTo: return "le"; case SearchOperation.IsGreaterThan: return "gt"; case SearchOperation.IsGreaterOrEqualTo: return "ge"; case SearchOperation.IsIn: return "in"; case SearchOperation.IsNotIn: return "ni"; case SearchOperation.BeginsWith: return "bw"; case SearchOperation.DoesNotBeginWith: return "bn"; case SearchOperation.EndsWith: return "ew"; case SearchOperation.DoesNotEndWith: return "en"; case SearchOperation.Contains: return "cn"; case SearchOperation.DoesNotContain: return "nc"; default: return "eq"; } }
public SingleArgCondition(string properyName, SearchOperation operation, object value) { _PropertyName = properyName; _Operation = operation; _value = value; }
private static Expression <Func <SearchResultItem, bool> > GetRangeExpression(Expression <Func <SearchResultItem, bool> > predicate, SearchCriteria criteria, SearchOperation operation) { var inclusion = (criteria.Filter == FilterType.InclusiveRange) ? Inclusion.Both : Inclusion.None; var boost = criteria.Boost; var value = criteria.Value; if (value is object[]) { switch (value) { case string[] s: value = s; break; case DateTime[] datetime: value = datetime; break; case double[] d: value = d; break; case int[] i: value = i; break; } } switch (value) { case string[] _: var pairString = (string[])value; var leftString = pairString[0]; var rightString = pairString[1]; predicate = criteria.Invert ? predicate.AddPredicate(i => !i[criteria.Field].Between(leftString, rightString, inclusion).Boost(boost), operation) : predicate.AddPredicate(i => i[criteria.Field].Between(leftString, rightString, inclusion).Boost(boost), operation); break; case DateTime[] _: var pairDateTime = (DateTime[])value; var leftDateTime = pairDateTime[0].ToString("yyyyMMdd"); var rightDateTime = pairDateTime[1].ToString("yyyyMMdd"); predicate = criteria.Invert ? predicate.AddPredicate(i => !i[criteria.Field].Between(leftDateTime, rightDateTime, inclusion).Boost(boost), operation) : predicate.AddPredicate(i => i[criteria.Field].Between(leftDateTime, rightDateTime, inclusion).Boost(boost), operation); break; case double[] _: var pairDouble = (double[])value; var leftDouble = pairDouble[0]; var rightDouble = pairDouble[1]; predicate = criteria.Invert ? predicate.AddPredicate(i => !((double)i[(ObjectIndexerKey)criteria.Field]).Between(leftDouble, rightDouble, inclusion).Boost(boost), operation) : predicate.AddPredicate(i => ((double)i[(ObjectIndexerKey)criteria.Field]).Between(leftDouble, rightDouble, inclusion).Boost(boost), operation); break; case int[] _: var pairInt = (int[])value; var leftInt = pairInt[0]; var rightInt = pairInt[1]; predicate = criteria.Invert ? predicate.AddPredicate(i => !((int)i[(ObjectIndexerKey)criteria.Field]).Between(leftInt, rightInt, inclusion).Boost(boost), operation) : predicate.AddPredicate(i => ((int)i[(ObjectIndexerKey)criteria.Field]).Between(leftInt, rightInt, inclusion).Boost(boost), operation); break; } return(predicate); }
public Expression <Func <SearchResultItem, bool> > ProcessCriteria(SearchCriteria[] criterias, SearchOperation operation) { var predicate = operation == SearchOperation.Or ? PredicateBuilder.False <SearchResultItem>() : PredicateBuilder.True <SearchResultItem>(); if (criterias != null) { foreach (var criteria in criterias) { if (criteria.Value == null) { continue; } var boost = criteria.Boost; var comparer = criteria.CaseSensitive.HasValue && criteria.CaseSensitive.Value ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase; switch (criteria.Filter) { case FilterType.DescendantOf: var root = ObjectToString(criteria.Value); if (string.IsNullOrEmpty(root) || !ShortID.IsShortID(root)) { WriteError(typeof(ArgumentException), "The value for DescendantOf criteria must be an Item or ID.", ErrorIds.InvalidOperation, ErrorCategory.InvalidArgument, criteria.Value); return(null); } predicate = criteria.Invert ? predicate.AddPredicate(i => !i["_path"].Contains(root).Boost(boost), operation) : predicate.AddPredicate(i => i["_path"].Contains(root).Boost(boost), operation); break; case FilterType.StartsWith: var startsWith = ObjectToString(criteria.Value); predicate = criteria.Invert ? predicate.AddPredicate(i => !i[criteria.Field].StartsWith(startsWith, comparer).Boost(boost), operation) : predicate.AddPredicate(i => i[criteria.Field].StartsWith(startsWith, comparer).Boost(boost), operation); break; case FilterType.Contains: if (comparer == StringComparison.OrdinalIgnoreCase && criteria.CaseSensitive.HasValue) { WriteWarning("Case insensitiveness is not supported on Contains criteria due to platform limitations."); } var contains = ObjectToString(criteria.Value); predicate = criteria.Invert ? predicate.AddPredicate(i => !i[criteria.Field].Contains(contains).Boost(boost), operation) : predicate.AddPredicate(i => i[criteria.Field].Contains(contains).Boost(boost), operation); break; case FilterType.ContainsAny: if (comparer == StringComparison.OrdinalIgnoreCase && criteria.CaseSensitive.HasValue) { WriteWarning("Case insensitiveness is not supported on Contains criteria due to platform limitations."); } var valuesAny = ObjectToStringArray(criteria.Value); predicate = criteria.Invert ? predicate.AddPredicate(valuesAny.Aggregate(PredicateBuilder.True <SearchResultItem>(), (current, keyword) => current.Or(c => !((string)c[(ObjectIndexerKey)criteria.Field]).Contains(keyword)))) : predicate.AddPredicate(valuesAny.Aggregate(PredicateBuilder.True <SearchResultItem>(), (current, keyword) => current.Or(c => ((string)c[(ObjectIndexerKey)criteria.Field]).Contains(keyword)))); break; case FilterType.ContainsAll: if (comparer == StringComparison.OrdinalIgnoreCase && criteria.CaseSensitive.HasValue) { WriteWarning("Case insensitiveness is not supported on Contains criteria due to platform limitations."); } var valuesAll = ObjectToStringArray(criteria.Value); predicate = criteria.Invert ? predicate.AddPredicate(valuesAll.Aggregate(PredicateBuilder.True <SearchResultItem>(), (current, keyword) => current.And(c => !((string)c[(ObjectIndexerKey)criteria.Field]).Contains(keyword)))) : predicate.AddPredicate(valuesAll.Aggregate(PredicateBuilder.True <SearchResultItem>(), (current, keyword) => current.And(c => ((string)c[(ObjectIndexerKey)criteria.Field]).Contains(keyword)))); break; case FilterType.EndsWith: var endsWith = ObjectToString(criteria.Value); predicate = criteria.Invert ? predicate.AddPredicate(i => !i[criteria.Field].EndsWith(endsWith, comparer).Boost(boost), operation) : predicate.AddPredicate(i => i[criteria.Field].EndsWith(endsWith, comparer).Boost(boost), operation); break; case FilterType.Equals: var equals = ObjectToString(criteria.Value); predicate = criteria.Invert ? predicate.AddPredicate(i => !i[criteria.Field].Equals(equals, comparer).Boost(boost), operation) : predicate.AddPredicate(i => i[criteria.Field].Equals(equals, comparer).Boost(boost), operation); break; case FilterType.Fuzzy: var fuzzy = ObjectToString(criteria.Value); predicate = criteria.Invert ? predicate.AddPredicate(i => !i[criteria.Field].Like(fuzzy).Boost(boost), operation) : predicate.AddPredicate(i => i[criteria.Field].Like(fuzzy).Boost(boost), operation); break; case FilterType.InclusiveRange: case FilterType.ExclusiveRange: predicate = GetRangeExpression(predicate, criteria, operation); break; case FilterType.MatchesRegex: var regex = criteria.StringValue; predicate = criteria.Invert ? predicate.AddPredicate(i => !i[criteria.Field].Matches(regex).Boost(boost), operation) : predicate.AddPredicate(i => i[criteria.Field].Matches(regex).Boost(boost), operation); break; case FilterType.MatchesWildcard: var wildcard = criteria.StringValue; predicate = criteria.Invert ? predicate.AddPredicate(i => !i[criteria.Field].MatchWildcard(wildcard).Boost(boost), operation) : predicate.AddPredicate(i => i[criteria.Field].MatchWildcard(wildcard).Boost(boost), operation); break; } } } return(predicate); }
public SearchItem(SearchOperation searchType, List <SearchItem> searchItems) { SearchType = searchType; SearchItems = searchItems; }
/// <summary> /// Get iFolder Entries by Name /// </summary> /// <param name="ifolderID">The ID of the iFolder.</param> /// <param name="parentID">The ID of the Parent Entry.</param> /// <param name="operation">The Search Operation</param> /// <param name="pattern">The Search Pattern</param> /// <param name="index">The Search Start Index</param> /// <param name="max">The Search Max Count of Results</param> /// <param name="accessID">The Access User ID.</param> /// <returns>A Set of iFolderEntry Objects</returns> public static iFolderEntrySet GetEntriesByName(string ifolderID, string parentID, SearchOperation operation, string pattern, int index, int max, string accessID) { Store store = Store.GetStore(); Collection c = store.GetCollectionByID(ifolderID); if (c == null) { throw new iFolderDoesNotExistException(ifolderID); } // impersonate iFolder.Impersonate(c, accessID); // path string path; if ((parentID == null) || ifolderID.Equals(parentID)) { path = c.Name + "/"; } else { Node n = c.GetNodeByID(parentID); DirNode dirNode = (DirNode)DirNode.NodeFactory(c, n); path = dirNode.GetRelativePath() + "/"; } // match the pattern Regex regex = null; if ((pattern != null) && (pattern.Length > 0)) { switch (operation) { case SearchOperation.BeginsWith: pattern = "^" + pattern; break; case SearchOperation.EndsWith: pattern = pattern + "$"; break; case SearchOperation.Equals: pattern = "^" + pattern + "$"; break; case SearchOperation.Contains: default: break; } regex = new Regex(pattern, RegexOptions.IgnoreCase); } // find children deep ICSList children = c.Search(PropertyTags.FileSystemPath, path, SearchOp.Begins); // sort the list ArrayList sortList = new ArrayList(); foreach (ShallowNode sn in children) { if ((regex == null) || regex.Match(sn.Name).Success) { sortList.Add(sn); } } sortList.Sort(new EntryComparer()); // build the result list ArrayList list = new ArrayList(); int i = 0; foreach (ShallowNode sn in sortList) { if (sn.IsBaseType(NodeTypes.FileNodeType) || sn.IsBaseType(NodeTypes.DirNodeType)) { if ((i >= index) && (((max <= 0) || i < (max + index)))) { Node n = c.GetNodeByID(sn.ID); list.Add(iFolderEntry.GetEntry(c, n)); } ++i; } } return(new iFolderEntrySet((iFolderEntry[])list.ToArray(typeof(iFolderEntry)), i)); }
public static Expression <Func <SearchResultItem, bool> > AddPredicate(this Expression <Func <SearchResultItem, bool> > first, Expression <Func <SearchResultItem, bool> > second, SearchOperation operation = SearchOperation.And) { switch (operation) { case SearchOperation.And: return(first.And(second)); case SearchOperation.Or: return(first.Or(second)); default: return(first); } }
private static Expression <Func <T, bool> > GetComparisonExpression <T>(Expression <Func <T, bool> > predicate, SearchCriteria criteria, SearchOperation operation) where T : ISearchResult { var boost = criteria.Boost; var value = criteria.Value; switch (value) { case DateTime _: var compareDateTime = (DateTime)value; predicate = (criteria.Invert || criteria.Filter == FilterType.LessThan) ? predicate.AddPredicate(i => ((DateTime)i[(ObjectIndexerKey)criteria.Field] < compareDateTime).Boost(boost), operation) : predicate.AddPredicate(i => ((DateTime)i[(ObjectIndexerKey)criteria.Field] > compareDateTime).Boost(boost), operation); break; case double _: var compareDouble = (double)value; predicate = (criteria.Invert || criteria.Filter == FilterType.LessThan) ? predicate.AddPredicate(i => ((double)i[(ObjectIndexerKey)criteria.Field] < compareDouble).Boost(boost), operation) : predicate.AddPredicate(i => ((double)i[(ObjectIndexerKey)criteria.Field] > compareDouble).Boost(boost), operation); break; case int _: var compareInt = (int)value; predicate = (criteria.Invert || criteria.Filter == FilterType.LessThan) ? predicate.AddPredicate(i => ((int)i[(ObjectIndexerKey)criteria.Field] < compareInt).Boost(boost), operation) : predicate.AddPredicate(i => ((int)i[(ObjectIndexerKey)criteria.Field] > compareInt).Boost(boost), operation); break; } return(predicate); }
public SearchEventArgs(string searchColumn, string searchString, SearchOperation searchOperation) : this() { this._searchColumn = searchColumn; this._searchString = searchString; this._searchOperation = searchOperation; }
/// <summary> /// Inserts inlined variable assignments into the schedule given by the operations list at their earliest possible position /// </summary> public void InsertInlinedVariableAssignmentsIntoSchedule(PatternGraph patternGraph, List<SearchOperation> operations) { // compute the number of inlined parameter variables int numInlinedParameterVariables = 0; foreach(PatternVariable var in patternGraph.variablesPlusInlined) { if(var.AssignmentSource != null && patternGraph.WasInlinedHere(var.originalSubpatternEmbedding)) ++numInlinedParameterVariables; } if(numInlinedParameterVariables == 0) return; // get the inlined parameter variables and the elements needed in order to compute their defining expression Dictionary<String, bool>[] neededElements = new Dictionary<String, bool>[numInlinedParameterVariables]; PatternVariable[] inlinedParameterVariables = new PatternVariable[numInlinedParameterVariables]; int curInlParamVar = 0; foreach(PatternVariable var in patternGraph.variablesPlusInlined) { if(var.AssignmentSource == null) continue; if(!patternGraph.WasInlinedHere(var.originalSubpatternEmbedding)) continue; neededElements[curInlParamVar] = new Dictionary<string, bool>(); foreach(String neededNode in var.AssignmentDependencies.neededNodes) neededElements[curInlParamVar][neededNode] = true; foreach(String neededEdge in var.AssignmentDependencies.neededEdges) neededElements[curInlParamVar][neededEdge] = true; inlinedParameterVariables[curInlParamVar] = var; ++curInlParamVar; } // iterate over all inlined parameter variables for(int i = 0; i < inlinedParameterVariables.Length; ++i) { int j; float costToEnd = 0; // find leftmost place in scheduled search plan for current assignment // by search from end of schedule forward until the first element the expression assigned is dependent on is found for(j = operations.Count - 1; j >= 0; --j) { SearchOperation op = operations[j]; if(op.Type == SearchOperationType.Condition || op.Type == SearchOperationType.Assign || op.Type == SearchOperationType.AssignVar || op.Type == SearchOperationType.NegativePattern || op.Type == SearchOperationType.IndependentPattern || op.Type == SearchOperationType.DefToBeYieldedTo) { continue; } if(neededElements[i].ContainsKey(((SearchPlanNode)op.Element).PatternElement.Name)) { costToEnd = op.CostToEnd; break; } } SearchOperation so = new SearchOperation(SearchOperationType.AssignVar, inlinedParameterVariables[i], null, costToEnd); so.Expression = inlinedParameterVariables[i].AssignmentSource; operations.Insert(j + 1, so); } }
public virtual iFolderSet GetiFoldersBySearch(MemberRole role, DateTime after, SearchOperation operation, string pattern, int index, int max) { iFolderSet result = null; try { Authorize(); string accessID = GetAccessID(); result = iFolder.GetiFoldersByMember(accessID, role, after, operation, pattern, index, max, accessID); } catch (Exception e) { SmartException.Throw(e); } return(result); }
private void InsertInlinedIndependentCheckForDuplicateMatch(List<SearchOperation> operations) { bool isInlinedIndependentElementExisting = false; foreach(SearchOperation op in operations) { if(IsOperationAnInlinedIndependentElement(op)) { isInlinedIndependentElementExisting = true; break; } } if(isInlinedIndependentElementExisting) { // insert at end of schedule, just moved ahead over negatives and independents // TODO: if we can estimate condition overhead, it makes sense to move ahead over conditions, too int i = operations.Count - 1; while((operations[i].Type == SearchOperationType.NegativePattern || operations[i].Type == SearchOperationType.IndependentPattern) && i > 0) { --i; } SearchOperation so = new SearchOperation(SearchOperationType.InlinedIndependentCheckForDuplicateMatch, null, null, operations[i].CostToEnd); operations.Insert(i + 1, so); } }
private void InsertInlinedElementIdentityCheckIntoSchedule(PatternGraph patternGraph, List<SearchOperation> operations) { for(int i = 0; i < operations.Count; ++i) { PatternElement assignmentSource = null; if(operations[i].Element is SearchPlanNode) assignmentSource = ((SearchPlanNode)operations[i].Element).PatternElement.AssignmentSource; if(assignmentSource != null && operations[i].Type != SearchOperationType.Identity) { for(int j = 0; j < operations.Count; ++j) { SearchPlanNode binder = null; if(operations[j].Element is SearchPlanNode) binder = (SearchPlanNode)operations[j].Element; if(binder != null && binder.PatternElement == assignmentSource && operations[j].Type != SearchOperationType.Identity) { if(operations[i].Type != SearchOperationType.Assign && operations[j].Type != SearchOperationType.Assign) { int indexOfSecond = Math.Max(i, j); SearchOperation so = new SearchOperation(SearchOperationType.Identity, operations[i].Element, binder, operations[indexOfSecond].CostToEnd); operations.Insert(indexOfSecond + 1, so); break; } } } } } }
private bool IsOperationAnInlinedIndependentElement(SearchOperation so) { if(so.Element is SearchPlanNode) if(((SearchPlanNode)so.Element).PatternElement.OriginalIndependentElement != null) return true; return false; }
/// <summary> /// Generates a scheduled search plan for a given search plan graph /// </summary> public ScheduledSearchPlan ScheduleSearchPlan(SearchPlanGraph spGraph, PatternGraph patternGraph, bool isNegativeOrIndependent) { // the schedule List<SearchOperation> operations = new List<SearchOperation>(); // a set of search plan edges representing the currently reachable not yet visited elements PriorityQueue<SearchPlanEdge> activeEdges = new PriorityQueue<SearchPlanEdge>(); // first schedule all preset elements foreach(SearchPlanEdge edge in spGraph.Root.OutgoingEdges) { if(edge.Target.IsPreset && edge.Type != SearchOperationType.DefToBeYieldedTo) { foreach(SearchPlanEdge edgeOutgoingFromPresetElement in edge.Target.OutgoingEdges) activeEdges.Add(edgeOutgoingFromPresetElement); // note: here a normal preset is converted into a neg/idpt preset operation if in negative/independent pattern SearchOperation newOp = new SearchOperation( isNegativeOrIndependent ? SearchOperationType.NegIdptPreset : edge.Type, edge.Target, spGraph.Root, 0); operations.Add(newOp); } } // then schedule the initialization of all def to be yielded to elements and variables, // must come after the preset elements, as they may be used in the def initialization foreach(SearchPlanEdge edge in spGraph.Root.OutgoingEdges) { if(edge.Type == SearchOperationType.DefToBeYieldedTo && (!isNegativeOrIndependent || (edge.Target.PatternElement.pointOfDefinition == patternGraph && edge.Target.PatternElement.originalElement==null))) { SearchOperation newOp = new SearchOperation( SearchOperationType.DefToBeYieldedTo, edge.Target, spGraph.Root, 0); newOp.Expression = edge.Target.PatternElement.Initialization; operations.Add(newOp); } } foreach(PatternVariable var in patternGraph.variablesPlusInlined) { if(var.defToBeYieldedTo && (!isNegativeOrIndependent || var.pointOfDefinition == patternGraph && var.originalVariable == null)) { SearchOperation newOp = new SearchOperation( SearchOperationType.DefToBeYieldedTo, var, spGraph.Root, 0); newOp.Expression = var.initialization; operations.Add(newOp); } } // then schedule all map with storage / pick from index / pick from storage / pick from name index elements not depending on other elements foreach(SearchPlanEdge edge in spGraph.Root.OutgoingEdges) { if(edge.Type == SearchOperationType.MapWithStorage) { foreach(SearchPlanEdge edgeOutgoingFromPickedElement in edge.Target.OutgoingEdges) activeEdges.Add(edgeOutgoingFromPickedElement); SearchOperation newOp = new SearchOperation(edge.Type, edge.Target, spGraph.Root, 0); newOp.Storage = edge.Target.PatternElement.Storage; newOp.StorageIndex = edge.Target.PatternElement.StorageIndex; operations.Add(newOp); } } foreach(SearchPlanEdge edge in spGraph.Root.OutgoingEdges) { if(edge.Type == SearchOperationType.PickFromStorage) { foreach(SearchPlanEdge edgeOutgoingFromPickedElement in edge.Target.OutgoingEdges) activeEdges.Add(edgeOutgoingFromPickedElement); SearchOperation newOp = new SearchOperation(edge.Type, edge.Target, spGraph.Root, 0); newOp.Storage = edge.Target.PatternElement.Storage; operations.Add(newOp); } } foreach(SearchPlanEdge edge in spGraph.Root.OutgoingEdges) { if(edge.Type == SearchOperationType.PickFromIndex) { foreach(SearchPlanEdge edgeOutgoingFromPickedElement in edge.Target.OutgoingEdges) activeEdges.Add(edgeOutgoingFromPickedElement); SearchOperation newOp = new SearchOperation(edge.Type, edge.Target, spGraph.Root, 0); newOp.IndexAccess = edge.Target.PatternElement.IndexAccess; operations.Add(newOp); } } foreach(SearchPlanEdge edge in spGraph.Root.OutgoingEdges) { if(edge.Type == SearchOperationType.PickByName) { foreach(SearchPlanEdge edgeOutgoingFromPickedElement in edge.Target.OutgoingEdges) activeEdges.Add(edgeOutgoingFromPickedElement); SearchOperation newOp = new SearchOperation(edge.Type, edge.Target, spGraph.Root, 0); newOp.NameLookup = edge.Target.PatternElement.NameLookup; operations.Add(newOp); } } foreach(SearchPlanEdge edge in spGraph.Root.OutgoingEdges) { if(edge.Type == SearchOperationType.PickByUnique) { foreach(SearchPlanEdge edgeOutgoingFromPickedElement in edge.Target.OutgoingEdges) activeEdges.Add(edgeOutgoingFromPickedElement); SearchOperation newOp = new SearchOperation(edge.Type, edge.Target, spGraph.Root, 0); newOp.UniqueLookup = edge.Target.PatternElement.UniqueLookup; operations.Add(newOp); } } // iterate over all reachable elements until the whole graph has been scheduled(/visited), // choose next cheapest operation, update the reachable elements and the search plan costs SearchPlanNode lastNode = spGraph.Root; for(int i = 0; i < spGraph.Nodes.Length - spGraph.NumPresetElements - spGraph.NumIndependentStorageIndexElements; ++i) { foreach(SearchPlanEdge edge in lastNode.OutgoingEdges) { if(edge.Target.IsPreset) continue; if(edge.Target.PatternElement.Storage != null && edge.Target.PatternElement.GetPatternElementThisElementDependsOnOutsideOfGraphConnectedness()==null) continue; if(edge.Target.PatternElement.IndexAccess != null && edge.Target.PatternElement.GetPatternElementThisElementDependsOnOutsideOfGraphConnectedness()==null) continue; if(edge.Target.PatternElement.NameLookup != null && edge.Target.PatternElement.GetPatternElementThisElementDependsOnOutsideOfGraphConnectedness()==null) continue; if(edge.Target.PatternElement.UniqueLookup != null && edge.Target.PatternElement.GetPatternElementThisElementDependsOnOutsideOfGraphConnectedness()==null) continue; CostDecreaseForLeavingInlinedIndependent(edge); activeEdges.Add(edge); } SearchPlanEdge minEdge = activeEdges.DequeueFirst(); lastNode = minEdge.Target; SearchOperation newOp = new SearchOperation(minEdge.Type, lastNode, minEdge.Source, minEdge.Cost); newOp.Storage = minEdge.Target.PatternElement.Storage; newOp.StorageIndex = minEdge.Target.PatternElement.StorageIndex; newOp.IndexAccess = minEdge.Target.PatternElement.IndexAccess; newOp.NameLookup = minEdge.Target.PatternElement.NameLookup; newOp.UniqueLookup = minEdge.Target.PatternElement.UniqueLookup; foreach(SearchOperation op in operations) op.CostToEnd += minEdge.Cost; operations.Add(newOp); } // remove the elements stemming from inlined independents // they were added in the hope that they might help in matching this pattern, // they don't if they are matched after the elements of this pattern (in fact they only increase the costs then) RemoveInlinedIndependentElementsAtEnd(operations); // insert inlined element identity check into the schedule in case neither of the possible assignments was scheduled InsertInlinedElementIdentityCheckIntoSchedule(patternGraph, operations); // insert inlined variable assignments into the schedule InsertInlinedVariableAssignmentsIntoSchedule(patternGraph, operations); // insert conditions into the schedule InsertConditionsIntoSchedule(patternGraph.ConditionsPlusInlined, operations); float cost = operations.Count > 0 ? operations[0].CostToEnd : 0; return new ScheduledSearchPlan(patternGraph, operations.ToArray(), cost); }
public virtual iFolderEntrySet GetEntriesByName(string ifolderID, string parentID, SearchOperation operation, string pattern, int index, int max) { iFolderEntrySet result = null; try { result = iFolderEntry.GetEntriesByName(ifolderID, parentID, operation, pattern, index, max, GetAccessID()); } catch (Exception e) { SmartException.Throw(e); } return(result); }
public static Expression <Func <SearchResultItem, bool> > ProcessQueryRules(IProviderSearchContext context, string queryFilter, SearchOperation operation) { var predicate = operation == SearchOperation.Or ? PredicateBuilder.False <SearchResultItem>() : PredicateBuilder.True <SearchResultItem>(); var crawler = context.Index.Crawlers.FirstOrDefault(c => c is SitecoreItemCrawler); if (crawler == null) { return(predicate); } var database = ((SitecoreItemCrawler)crawler).Database; if (string.IsNullOrEmpty(database)) { return(predicate); } var ruleFactory = new Sitecore.ContentSearch.Rules.QueryableRuleFactory(); var rules = ruleFactory.ParseRules <Sitecore.ContentSearch.Rules.QueryableRuleContext <SearchResultItem> >(Factory.GetDatabase(database), queryFilter); foreach (var rule in rules.Rules) { if (rule.Condition == null) { continue; } var ruleContext = new Sitecore.ContentSearch.Rules.QueryableRuleContext <SearchResultItem>(context); var stack = new RuleStack(); rule.Condition.Evaluate(ruleContext, stack); rule.Execute(ruleContext); if (stack.Any()) { predicate = ruleContext.Where; } } return(predicate); }