public static void update_index(Guid applicationId, SearchDocType type, int batchSize, int sleepInterval = 20000) { //Update Tags Before Index Update: Because tagextraction uses IndexLastUpdateDate field if (type == SearchDocType.Node) { CNController.update_form_and_wiki_tags(applicationId, batchSize); } List <SearchDoc> updateSdList = SearchController.get_index_queue_items(applicationId, batchSize, type); List <SearchDoc> deletedSdList = updateSdList.Where(u => u.Deleted == true).ToList(); List <Guid> IDs = updateSdList.Select(u => u.ID).ToList(); deletedSdList.ForEach(sd => updateSdList.Remove(sd)); SearchUtilities.remove_docs(applicationId, deletedSdList); if (!RaaiVanSettings.Solr.Enabled) { Thread.Sleep(sleepInterval); } SearchUtilities.update_index(applicationId, updateSdList); SearchController.set_index_last_update_date(applicationId, type, IDs); }
private static void update_index(Guid applicationId, SearchDocType docType) { List <SearchDoc> docs = new List <SearchDoc>(); _remove_all_docs(applicationId); if (docType == SearchDocType.Node) { List <Node> nodes = CNController.get_nodes(applicationId, searchText: null, isDocument: null, isKnowledge: null); foreach (Node nd in nodes) { docs.Add(new SearchDoc() { ID = nd.NodeID.Value, AdditionalID = nd.AdditionalID, Title = nd.Name, Description = nd.Description, Type = SearchDocType.Node.ToString() }); } } _create_index(applicationId, docs); }
public void ProcessRequest(HttpContext context) { paramsContainer = new ParamsContainer(context, nullTenantResponse: true); if (!paramsContainer.ApplicationID.HasValue) { return; } string responseText = string.Empty; string command = PublicMethods.parse_string(context.Request.Params["Command"], false); switch (command) { case "Search": List <SearchDocType> itemTypes = new List <SearchDocType>(); SearchDocType tempDt = new SearchDocType(); foreach (string str in ListMaker.get_string_items(context.Request.Params["ItemTypes"], '|')) { if (Enum.TryParse <SearchDocType>(str, out tempDt)) { itemTypes.Add(tempDt); } } search(itemTypes, PublicMethods.parse_string(context.Request.Params["SearchText"]), PublicMethods.parse_int(context.Request.Params["LowerBoundary"]), PublicMethods.parse_int(context.Request.Params["Count"]), PublicMethods.parse_bool(context.Request.Params["Title"]), PublicMethods.parse_bool(context.Request.Params["Description"]), PublicMethods.parse_bool(context.Request.Params["Content"]), PublicMethods.parse_bool(context.Request.Params["Tags"]), PublicMethods.parse_bool(context.Request.Params["FileContent"]), PublicMethods.parse_bool(context.Request.Params["ForceHasContent"]), ListMaker.get_guid_items(context.Request.Params["TypeIDs"], '|'), ListMaker.get_string_items(context.Request.Params["Types"], '|'), PublicMethods.parse_bool(context.Request.Params["ShowExactItems"]), PublicMethods.parse_bool(context.Request.Params["SuggestNodeTypes"]), PublicMethods.parse_bool(context.Request.Params["Excel"]), PublicMethods.parse_bool(context.Request.Params["FormDetails"]), PublicMethods.fromJSON(PublicMethods.parse_string(context.Request.Params["ColumnNames"])), ref responseText); _return_response(ref responseText); return; } paramsContainer.return_response(PublicConsts.BadRequestResponse); }
public static bool SetIndexLastUpdateDate(Guid applicationId, SearchDocType itemType, List <Guid> IDs) { string spName = GetFullyQualifiedName("SetIndexLastUpdateDate"); try { return(ProviderUtil.succeed(ProviderUtil.execute_reader(spName, applicationId, itemType.ToString(), ProviderUtil.list_to_string <Guid>(ref IDs), ',', DateTime.Now))); } catch (Exception ex) { LogController.save_error_log(applicationId, null, spName, ex, ModuleIdentifier.SRCH); return(false); } }
public static SearchDoc ToSearchDoc(Guid id, Guid?typeID, string content, string additionalID, bool deleted, string type, SearchDocType docType, string title = null, string tags = null, string description = null, string fileContect = null) { SearchDoc sd = new SearchDoc(); sd.ID = id; sd.Deleted = deleted; sd.TypeID = typeID; sd.Type = type; sd.AdditionalID = additionalID; sd.Title = title; sd.Description = description; sd.Tags = tags; sd.Content = content; sd.FileContent = fileContect; sd.SearchDocType = docType; return(sd); }
public static SearchDoc ToSearchDoc(SolrDoc doc) { try { SearchDocType docType = SearchDocType.All; string docId = doc.get_main_id(); if (!Enum.TryParse <SearchDocType>(doc.SearchDocType, out docType)) { return(null); } return(ToSearchDoc(Guid.Parse(docId), string.IsNullOrEmpty(doc.TypeID) ? (Guid?)null : Guid.Parse(doc.TypeID), doc.Content, doc.AdditionalID, doc.Deleted, doc.Type, docType, doc.Title, doc.Tags, doc.Description, doc.FileContent)); } catch { return(null); } }
public static bool set_index_last_update_date(Guid applicationId, SearchDocType itemType, List <Guid> IDs) { return(DataProvider.SetIndexLastUpdateDate(applicationId, itemType, IDs)); }
public static List <SearchDoc> get_index_queue_items(Guid applicationId, int count, SearchDocType type) { List <SearchDoc> retList = new List <SearchDoc>(); DataProvider.GetIndexQueueItems(applicationId, ref retList, count, type.ToString()); return(retList); }
public static void start_update(object rvThread) { RVJob trd = (RVJob)rvThread; if (!trd.TenantID.HasValue || !RaaiVanSettings.IndexUpdate.Index(trd.TenantID.Value)) { return; } if (!trd.TenantID.HasValue) { return; } if (!trd.StartTime.HasValue) { trd.StartTime = RaaiVanSettings.IndexUpdate.StartTime(trd.TenantID.Value); } if (!trd.EndTime.HasValue) { trd.EndTime = RaaiVanSettings.IndexUpdate.EndTime(trd.TenantID.Value); } while (true) { //sleep thread be madate Interval saniye if (!trd.Interval.HasValue) { trd.Interval = RaaiVanSettings.IndexUpdate.Interval(trd.TenantID.Value); } else { Thread.Sleep(trd.Interval.Value); } //agar dar saati hastim ke bayad update shavad edame midahim if (!trd.check_time()) { continue; } System.Diagnostics.Stopwatch sw = System.Diagnostics.Stopwatch.StartNew(); sw.Start(); try { //Aya Index ha dar RAM ham zakhire shavand bool inRam = RaaiVanSettings.IndexUpdate.Ram(trd.TenantID.Value); //tartibe index kardane Search Doc ha cheghoone bashad for (int i = 0; i < RaaiVanSettings.IndexUpdate.Priorities(trd.TenantID.Value).Length; i++) { SearchDocType type = SearchDocType.All; if (!Enum.TryParse(RaaiVanSettings.IndexUpdate.Priorities(trd.TenantID.Value)[i], out type)) { type = SearchDocType.All; } update_index(trd.TenantID.Value, type, RaaiVanSettings.IndexUpdate.BatchSize(trd.TenantID.Value), 20000); Thread.Sleep(20000); } } catch (Exception ex) { LogController.save_error_log(trd.TenantID.Value, null, "IndexUpdateJob", ex, ModuleIdentifier.SRCH, LogLevel.Fatal); } trd.LastActivityDate = DateTime.Now; sw.Stop(); trd.LastActivityDuration = sw.ElapsedMilliseconds; } }