public JsonResult CreateIndex() { try { var list = _db.Articles.Where(d => d.Active).Select(m => new SearchData { Id = $"ARTICLE{m.Id}", Name = m.Title, Description = string.IsNullOrEmpty(m.Summary)? StringHelper.StripTagsCharArray(m.Body) : m.Summary, ImageUrl = string.IsNullOrEmpty(m.Thumbnail)?string.Empty: m.Thumbnail, Url = m.CategoryId == 1 ? $"{SettingsManager.Site.SiteDomainName}/article/detail/{m.Id}" : $"{SettingsManager.Site.SiteDomainName}/article/detail/{m.Id}", CreatedDate = m.Pubdate }).ToList(); //var products = _mapper.Map<List<Product>, List<SearchData>>(list); LuceneHelper.AddUpdateLuceneIndex(list); AR.SetSuccess(String.Format(Messages.AlertActionSuccess, EntityNames.Article)); return(Json(AR, JsonRequestBehavior.DenyGet)); } catch (Exception er) { AR.Setfailure(er.Message); return(Json(AR, JsonRequestBehavior.DenyGet)); } }
public IQueryBuilder MustNotAnyOf(params ISearchTerm[] terms) { var inner = LuceneHelper.JoinOr(terms.Select(x => x.ToLuceneString())); _query.Append($" {LuceneHelper.MUST_NOT_OPERATOR}{inner}"); return(this); }
private static async void RunSearch(SearchViewModel searchView, string searchText) { if (string.IsNullOrEmpty(searchText) || ApplicationView.CurrentIndexFile == null || !LuceneHelper.IsValidIndexDirectory(ApplicationView.CurrentIndexFile.IndexDirectory)) { return; } Guid opId = Guid.Empty; CancellationToken cancelToken; if (!ApplicationView.BeginOperation(StatusKind.Searching, out opId, out cancelToken)) { return; } Action lazySearchFinishedAction = () => ApplicationView.EndOperation(opId); if (searchView.IsSearchingInResults) { await Task.Run(() => searchView.RunFileSearch(ApplicationView.CurrentIndexFile, searchText, searchView.FixedResultFiles, cancelToken, lazySearchFinishedAction), cancelToken); } else { await Task.Run(() => searchView.RunSearch(ApplicationView.CurrentIndexFile, searchText, cancelToken, lazySearchFinishedAction), cancelToken); } }
public override void Excute(System.Web.Caching.CacheItemRemovedReason reason) { LuceneHelper helper = new LuceneHelper(); helper.IndexingAfterComplete += new AfterIndexingCoplete(HitPage); helper.BuildingIndex(); //base.Excute(reason); }
private Document BuildDocument(string file) { if (string.IsNullOrEmpty(file)) { return(null); } Document doc = new Document(); try { using (StreamReader sr = new StreamReader(file)) { string fileDirectory = Path.GetDirectoryName(file); doc.Add(new Field(Constants.IndexFields.Directory, fileDirectory, Field.Store.YES, Field.Index.NOT_ANALYZED)); doc.Add(new Field(Constants.IndexFields.Filename, Path.GetFileNameWithoutExtension(file), Field.Store.YES, Field.Index.NOT_ANALYZED)); doc.Add(new Field(Constants.IndexFields.Extension, Path.GetExtension(file), Field.Store.YES, Field.Index.NOT_ANALYZED)); doc.Add(new Field(Constants.IndexFields.LastModified, new FileInfo(file).LastWriteTime.Ticks.ToString(), Field.Store.YES, Field.Index.NOT_ANALYZED)); //TODO split content when too long ( > int.max ) string content = sr.ReadToEnd(); doc.Add(new Field(Constants.IndexFields.AnalizedDirectory, LuceneHelper.ExpandTokenBreak(fileDirectory.ToLower()), Field.Store.NO, Field.Index.ANALYZED)); doc.Add(new Field(Constants.IndexFields.Content, LuceneHelper.ExpandTokenBreak(content), Field.Store.NO, Field.Index.ANALYZED)); doc.Add(new Field(Constants.IndexFields.ContentCaseInsensitive, LuceneHelper.ExpandTokenBreak(content.ToLower()), Field.Store.NO, Field.Index.ANALYZED)); } } catch { return(null); } return(doc); }
public JsonResult CreateIndex() { try { var list = _db.SimpleProducts.Where(m => m.Active).Select(m => new SearchData { Id = "SP" + m.Id, Name = m.ProductName, Description = m.Summary, ImageUrl = m.Thumbnail, Url = SettingsManager.Site.SiteDomainName + "/products/detail/" + m.Id, CreatedDate = m.CreatedDate }).ToList(); LuceneHelper.AddUpdateLuceneIndex(list); AR.SetSuccess(String.Format(Messages.AlertActionSuccess, EntityNames.Product)); return(Json(AR, JsonRequestBehavior.DenyGet)); } catch (Exception er) { AR.Setfailure(er.Message); return(Json(AR, JsonRequestBehavior.DenyGet)); } }
public JsonResult CreateIndex() { try { var cases = _db.Cases.Where(d => d.Active == true).ToList(); var list = cases.Select(m => new SearchData { Id = "CASE" + m.Id, Name = m.Title, Description = string.IsNullOrEmpty(m.Summary)? StringHelper.StripTagsCharArray(m.Body) : m.Summary, ImageUrl = string.IsNullOrEmpty(m.Thumbnail)?string.Empty: m.Thumbnail, Url = "/cases/detail/" + m.Id, CreatedDate = m.Pubdate }).ToList(); LuceneHelper.AddUpdateLuceneIndex(list); AR.SetSuccess(String.Format(Messages.AlertActionSuccess, EntityNames.Case)); return(Json(AR, JsonRequestBehavior.DenyGet)); } catch (Exception er) { AR.Setfailure(er.Message); return(Json(AR, JsonRequestBehavior.DenyGet)); } }
internal IEnumerable <string> GetAvailableFileFilters(IndexViewModel indexDirectory) { if (indexDirectory == null) { return(Enumerable.Empty <string>()); } if (!LuceneHelper.IsValidIndexDirectory(indexDirectory.IndexDirectory)) { return(Enumerable.Empty <string>()); } var availableExtensions = new List <string>(); using (var reader = IndexReader.Open(FSDirectory.Open(indexDirectory.IndexDirectory), true)) { var termEnum = reader.Terms(); while (termEnum.Next()) { var curTerm = termEnum.Term; if (curTerm.Field != Constants.IndexFields.Extension) { continue; } if (!availableExtensions.Contains(curTerm.Text)) { availableExtensions.Add("*" + curTerm.Text); } } } return(availableExtensions); }
public async Task <ActionResult> Search(string wd = "", int page = 1, int size = 10) { var nul = new List <PostOutputDto>(); int count = 0; ViewBag.Elapsed = 0; ViewBag.Total = count; ViewBag.Keyword = wd; if (Regex.Match(wd, CommonHelper.BanRegex).Length > 0 || Regex.Match(wd, CommonHelper.ModRegex).Length > 0) { //ViewBag.Wd = ""; return(RedirectToAction("Search")); } var hotSearches = new List <KeywordsRankOutputDto>(); ViewBag.hotSearches = hotSearches; using (RedisHelper redisHelper = RedisHelper.GetInstance()) { string key = Request.UserHostAddress + Request.UserAgent; if (redisHelper.KeyExists(key) && !redisHelper.GetString(key).Equals(wd)) { ViewBag.ErrorMsg = "10秒内只能搜索1次!"; return(View(nul)); } redisHelper.SetString(key, wd, TimeSpan.FromSeconds(10)); } wd = wd.Trim().Replace("+", " "); var sw = new Stopwatch(); if (!string.IsNullOrWhiteSpace(wd) && !wd.Contains("锟斤拷")) { if (page == 1) { SearchDetailsBll.AddEntity(new SearchDetails() { KeyWords = wd, SearchTime = DateTime.Now, IP = Request.UserHostAddress }); } sw.Start(); var query = LuceneHelper.Search(wd).ToList(); var posts = query.Skip((page - 1) * size).Take(size).ToList(); sw.Stop(); ViewBag.Elapsed = sw.Elapsed.TotalMilliseconds; ViewBag.Total = query.Count; SearchDetailsBll.SaveChanges(); return(View(posts)); } var start = DateTime.Today.AddDays(-7); hotSearches = (await SearchDetailsBll.LoadEntitiesFromCacheNoTrackingAsync(s => s.SearchTime > start, s => s.SearchTime, false).ConfigureAwait(true)).GroupBy(s => s.KeyWords.ToLower()).OrderByDescending(g => g.Count()).Take(7).Select(g => new KeywordsRankOutputDto() { KeyWords = g.FirstOrDefault()?.KeyWords, SearchCount = g.Count() }).ToList(); ViewBag.hotSearches = hotSearches; return(View(nul)); }
public IndexSearcherInstance GetIndexSearcher(object folder) { var targetFolder = GetFolderFromObject(folder); var indexSearcher = LuceneHelper.GetIndexSearcher(targetFolder); return(new IndexSearcherInstance(this.Engine.Object.InstancePrototype, indexSearcher)); }
public IActionResult Search() { LuceneHelper lHelper = new LuceneHelper(_hostingEnvironment.WebRootPath); lHelper.Search("神农"); lHelper.Search("六月份"); return(View()); }
/// <summary> /// 查询Lucene.NET /// </summary> /// <param name="top">数量</param> /// <param name="site_id">网站ID</param> /// <param name="channel_id">频道ID</param> /// <param name="category_id">类别ID</param> /// <param name="keyword">关键词</param> /// <returns></returns> public DataTable get_lucene_list(int top, int site_id, int channel_id, int category_id, string keywords) { DataTable dt = new DataTable(); if (site_id > 0 && null != keywords && keywords.Length > 1) { dt = LuceneHelper.Search(LuceneHelper.INDEX_DIR, top, site_id, channel_id, category_id, keywords); } return(dt); }
/// <summary> /// 查询Lucene.NET /// </summary> /// <param name="pageSize">每页显示数量</param> /// <param name="pageIndex">当前分页</param> /// <param name="site_id">网站ID</param> /// <param name="channel_id">频道ID</param> /// <param name="category_id">类别ID</param> /// <param name="keyword">关键词</param> /// <param name="recordCount">结果总数量</param> /// <returns></returns> public DataTable get_lucene_list(int pageSize, int pageIndex, int site_id, int channel_id, int category_id, string keywords, out int recordCount) { recordCount = 0; DataTable dt = new DataTable(); if (site_id > 0 && null != keywords && keywords.Length > 0) { dt = LuceneHelper.Search(LuceneHelper.INDEX_DIR, pageSize, pageIndex, site_id, channel_id, category_id, keywords, out recordCount); } return(dt); }
private bool GetIsValidWholeWordMatch(GetMatchingLinesArgs args, string adjustedSearchLine, HighlightInfo match) { bool previousCharacterMatters = !LuceneHelper.IsValidTokenBreakCharactor(args.SearchString.FirstOrDefault()); char previousCharacter = adjustedSearchLine.ElementAtOrDefault(match.StartIndex - 1); bool nextCharacterMatters = !LuceneHelper.IsValidTokenBreakCharactor(args.SearchString.LastOrDefault()); char nextCharacter = adjustedSearchLine.ElementAtOrDefault(match.EndIndex); bool isValidWholeWordMatch = (!previousCharacterMatters || LuceneHelper.IsValidTokenBreakCharactor(previousCharacter)) && (!nextCharacterMatters || LuceneHelper.IsValidTokenBreakCharactor(nextCharacter)); return(isValidWholeWordMatch); }
public JsonResult ClearIndex() { if (LuceneHelper.ClearLuceneIndex()) { AR.SetSuccess(String.Format(Messages.AlertDeleteSuccess, "索引")); return(Json(AR, JsonRequestBehavior.DenyGet)); } else { AR.Setfailure("索引被锁,不能被清除,迟点再试!"); return(Json(AR, JsonRequestBehavior.DenyGet)); } }
public ActionResult Search(string txtSearch, int id = 1) { int pageNum = 1; int currentPageNo = id; IndexSearcher search = new IndexSearcher(directory, true); BooleanQuery bQuery = new BooleanQuery(); //总的结果条数 List <Article> list = new List <Article>(); int recCount = 0; //处理搜索关键词 txtSearch = LuceneHelper.GetKeyWordsSplitBySpace(txtSearch); //多个字段查询 标题和内容title, content MultiFieldQueryParser parser = new MultiFieldQueryParser(Lucene.Net.Util.Version.LUCENE_30, new string[] { "title", "Content" }, new PanGuAnalyzer()); Query query = parser.Parse(txtSearch); //Occur.Should 表示 Or , Occur.MUST 表示 and bQuery.Add(query, Occur.MUST); if (bQuery != null && bQuery.GetClauses().Length > 0) { //盛放查询结果的容器 TopScoreDocCollector collector = TopScoreDocCollector.Create(1000, true); //使用query这个查询条件进行搜索,搜索结果放入collector search.Search(bQuery, null, collector); recCount = collector.TotalHits; //从查询结果中取出第m条到第n条的数据 ScoreDoc[] docs = collector.TopDocs((currentPageNo - 1) * pageNum, pageNum).ScoreDocs; //遍历查询结果 for (int i = 0; i < docs.Length; i++) { //只有 Field.Store.YES的字段才能用Get查出来 Document doc = search.Doc(docs[i].Doc); list.Add(new Article() { Id = doc.Get("id"), Title = LuceneHelper.CreateHightLight(txtSearch, doc.Get("title")), //高亮显示 Content = LuceneHelper.CreateHightLight(txtSearch, doc.Get("Content")) //高亮显示 }); } } //分页 PagedList <Article> plist = new PagedList <Article>(list, currentPageNo, pageNum, recCount); plist.TotalItemCount = recCount; plist.CurrentPageIndex = currentPageNo; return(View("Index", plist)); }
public SPIndexWriterInstance GetIndexWriter(object folder, object createIndex) { var targetFolder = GetFolderFromObject(folder); var bCreateIndex = false; if (createIndex != null && createIndex != Null.Value && createIndex != Undefined.Value && createIndex is Boolean) { bCreateIndex = (bool)createIndex; } var indexWriter = LuceneHelper.GetIndexWriterSingleton(targetFolder, bCreateIndex); return(new SPIndexWriterInstance(this.Engine.Object.InstancePrototype, indexWriter, targetFolder)); }
public ActionResult AddToIndex(SearchDataIM sampleData) { if (!ModelState.IsValid) { AR.Setfailure(GetModelErrorMessage()); return(Json(AR, JsonRequestBehavior.DenyGet)); } var im = _mapper.Map <SearchData>(sampleData); LuceneHelper.AddUpdateLuceneIndex(im); AR.SetSuccess(String.Format(Messages.AlertCreateSuccess, "索引目录")); return(Json(AR, JsonRequestBehavior.DenyGet)); }
public JsonResult ClearIndexRecord(string id) { try { LuceneHelper.ClearLuceneIndexRecord(id); AR.SetSuccess(String.Format(Messages.AlertDeleteSuccess, "索引")); return(Json(AR, JsonRequestBehavior.DenyGet)); } catch (Exception er) { AR.Setfailure(er.Message); return(Json(AR, JsonRequestBehavior.DenyGet)); } }
public IActionResult Contact() { ViewData["Message"] = "Your contact page."; LuceneHelper lHelper = new LuceneHelper(_hostingEnvironment.WebRootPath); var eA = new EditViewArticle() { Id = 1007, Title = "吃神农放心肉 享健康人生——2018“神农杯”高尔夫邀请赛圆满结束", Summary = "5月6日,清风和畅 天高云阔 在绿草如茵、风景如画的 昆明玉龙湾高尔夫球场 2018神农杯高尔夫邀请赛华丽开杆 一百多位神农合作伙伴参加了比赛", CreateTime = DateTime.Now }; lHelper.AddIndex(eA); return(View()); }
private IEnumerable <BooleanClause> BuildBlacklistQueryClauses(IEnumerable <string> blacklist) { if (blacklist == null || !blacklist.Any()) { return(Enumerable.Empty <BooleanClause>()); } List <BooleanClause> clauses = new List <BooleanClause>(); foreach (var cur in blacklist) { string adjustedString = LuceneHelper.ExpandTokenBreak(cur.ToLower()).TrimEnd(Path.DirectorySeparatorChar); clauses.Add(new BooleanClause(BuildMatchWholeWordQuery(Constants.IndexFields.AnalizedDirectory, adjustedString), Occur.MUST_NOT)); } return(clauses); }
public ActionResult Index(string searchTerm, int?page) { var vm = new LuceneListVM() { SearchTerm = searchTerm, PageIndex = (page ?? 1) - 1, PageSize = SettingsManager.Lucene.PageSize }; // create default Lucene search index directory if (!Directory.Exists(LuceneHelper._luceneDir)) { Directory.CreateDirectory(LuceneHelper._luceneDir); } int totalCount = 0; // perform Lucene search List <SearchData> _searchResults = LuceneHelper.SearchDefault(vm.PageIndex, vm.PageSize, out totalCount, searchTerm).ToList(); // setup and return view model var search_field_list = new List <SelectedList> { new SelectedList { Text = "--所有字段--", Value = "" }, new SelectedList { Text = "标题", Value = "Name" }, new SelectedList { Text = "网址", Value = "Name" }, new SelectedList { Text = "内容", Value = "Description" } }; vm.TotalCount = totalCount; vm.SearchIndexData = new StaticPagedList <SearchData>(_searchResults, vm.PageIndex + 1, vm.PageSize, vm.TotalCount);; vm.SearchFieldList = search_field_list; ViewBag.PageSizes = new SelectList(Site.PageSizes()); return(View(vm)); }
public void AddObjectToIndex(object obj) { //TODO: if the obj is a SPListItemInstance, create a document from the list item. var objString = JSONObject.Stringify(this.Engine, obj, null, null); var objectToAdd = JObject.Parse(objString); var doc = LuceneHelper.ConvertObjectToDocument(objectToAdd); try { m_indexWriter.AddDocument(doc); } catch (OutOfMemoryException) { LuceneHelper.CloseIndexWriterSingleton(m_targetFolder); } }
private Query BuildMatchAnywhereQuery(IndexReader indexReader, string searchString, bool matchCase, bool useWildcards) { if (useWildcards) { BooleanQuery resultQuery = new BooleanQuery(); var patternParts = GetWildcardPatternParts(searchString); foreach (var part in patternParts) { resultQuery.Add(BuildMatchAnywhereQuery(indexReader, LuceneHelper.ExpandTokenBreak(part), matchCase), Occur.MUST); } return(resultQuery); } else { return(BuildMatchAnywhereQuery(indexReader, LuceneHelper.ExpandTokenBreak(searchString), matchCase)); } }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); //Giving CreateIndexController the chosen ILuceneHelperImplementation and IQueryParserImplemenation LuceneHelper LuceneClass = new LuceneHelper(); BooleanQueryParser BooleanQueryParser = new BooleanQueryParser(); CreateIndexController CreateIndexController = new CreateIndexController(LuceneClass, BooleanQueryParser); //BooleanLexicalQueryParser BooleanLexicalQueryParser = new BooleanLexicalQueryParser(); //CreateIndexController CreateIndexController = new CreateIndexController(LuceneClass, BooleanLexicalQueryParser); CreateIndexView CreateIndexView = new CreateIndexView(); CreateIndexView.SetCreateIndexController(CreateIndexController); Application.Run(CreateIndexView); }
private static async Task <bool> LoadIndexSilent(string indexFile) { if (ApplicationView.CurrentIndexFile != null && ApplicationView.CurrentIndexFile.IndexFile == indexFile) { return(true); } Guid opId = Guid.Empty; if (!ApplicationView.BeginOperation(StatusKind.Loading, out opId)) { return(false); } try { ApplicationView.CurrentIndexFile = IndexViewModel.Load(indexFile); if (ApplicationView.CurrentIndexFile == null) { return(false); } bool validIndexDirectoryFound = await Task.Run <bool>(() => LuceneHelper.IsValidIndexDirectory(ApplicationView.CurrentIndexFile.IndexDirectory)); if (!validIndexDirectoryFound) { ApplicationView.CurrentIndexFile = null; return(false); } ApplicationView.UpdateSearchFilter(); ApplicationView.FileWatcher.WatchDirectories(ApplicationView.CurrentIndexFile.SourceDirectories); } finally { ApplicationView.EndOperation(opId); } RefreshIndexAtStartup(ApplicationView.CurrentIndexFile); return(true); }
public JsonResult CreateIndex() { try { var list = _db.Pages.Where(d => d.Active).Select(m => new SearchData { Id = $"PAGE{m.Id}", Name = m.Title, Description = StringHelper.StripTagsCharArray(m.Body), Url = $"{SettingsManager.Site.SiteDomainName}/page-{m.SeoName}" }).ToList(); LuceneHelper.AddUpdateLuceneIndex(list); AR.SetSuccess(String.Format(Messages.AlertActionSuccess, EntityNames.Page)); return(Json(AR, JsonRequestBehavior.DenyGet)); } catch (Exception er) { AR.Setfailure(er.Message); return(Json(AR, JsonRequestBehavior.DenyGet)); } }
public SimpleFacetedSearchInstance GetSimpleFacetedSearch(object folder, object groupByFields) { if (groupByFields == null || groupByFields == Null.Value || groupByFields == Undefined.Value) { throw new JavaScriptException(this.Engine, "Error", "Must specify the field(s) to group by as the second parameter."); } var groupByFieldsList = new List <string>(); if (groupByFields is ArrayInstance) { groupByFieldsList.AddRange((groupByFields as ArrayInstance).ElementValues.OfType <string>()); } else { groupByFieldsList.Add(groupByFields.ToString()); } var targetFolder = GetFolderFromObject(folder); var simpleFacetedSearch = LuceneHelper.GetSimpleFacetedSearch(targetFolder, groupByFieldsList.ToArray()); return(new SimpleFacetedSearchInstance(this.Engine.Object.InstancePrototype, simpleFacetedSearch)); }
public void RemoveFromIndex(object folder, object query) { if (query == Null.Value || query == Undefined.Value || query == null) { throw new JavaScriptException(this.Engine, "Error", "A query parameter must be specified to indicate the documents to remove from the index. Use '*' to specify all documents."); } Query lQuery; var queryString = query.ToString(); var queryType = query.GetType(); if (queryString == "*") { lQuery = new MatchAllDocsQuery(); } else if (queryType.IsSubclassOfRawGeneric(typeof(QueryInstance <>))) { var queryProperty = queryType.GetProperty("Query", BindingFlags.Instance | BindingFlags.Public); lQuery = queryProperty.GetValue(query, null) as Query; } else { throw new JavaScriptException(this.Engine, "Error", "The query parameter was not a query."); } try { m_indexWriter.DeleteDocuments(lQuery); } catch (OutOfMemoryException) { LuceneHelper.CloseIndexWriterSingleton(m_targetFolder); } }
public ActionResult Details(int id, string kw) { List <string> list = new List <string>(); if (!string.IsNullOrEmpty(kw)) { list = LuceneHelper.CutKeywords(kw); if (Regex.Match(kw, BanRegex).Length > 0 || Regex.Match(kw, ModRegex).Length > 0) { ViewBag.Keyword = ""; return(RedirectToAction("Details", "Post", new { id })); } } Post post = PostBll.GetById(id); if (post != null) { ViewBag.Keyword = post.Keyword + "," + post.Label; UserInfoOutputDto user = Session.GetByRedis <UserInfoOutputDto>(SessionKey.UserInfo) ?? new UserInfoOutputDto(); DateTime modifyDate = post.ModifyDate; ViewBag.Next = PostBll.GetFirstEntityFromL2CacheNoTracking(p => p.ModifyDate > modifyDate && (p.Status == Status.Pended || user.IsAdmin), p => p.ModifyDate); ViewBag.Prev = PostBll.GetFirstEntityFromL2CacheNoTracking(p => p.ModifyDate < modifyDate && (p.Status == Status.Pended || user.IsAdmin), p => p.ModifyDate, false); if (user.IsAdmin) { return(View("Details_Admin", post)); } if (post.Status != Status.Pended) { return(RedirectToAction("Post", "Home")); } if (string.IsNullOrEmpty(Session.GetByRedis <string>("post" + id))) { //post.ViewCount++; var record = post.PostAccessRecord.FirstOrDefault(r => r.AccessTime == DateTime.Today); if (record != null) { record.ClickCount += 1; } else { post.PostAccessRecord.Add(new PostAccessRecord { ClickCount = 1, AccessTime = DateTime.Today }); } PostBll.UpdateEntitySaved(post); Session.SetByRedis("post" + id, id.ToString()); } foreach (var s in list) { if (s.Contains(new[] { @"\?", @"\*", @"\+", @"\-", @"\[", @"\]", @"\{", @"\}", @"\(", @"\)", "�" })) { continue; } post.Content = Regex.IsMatch(s, @"^\p{P}.*") ? post.Content.Replace(s, $"<span style='color:red;background-color:yellow;font-size: 1.1em;font-weight:700;'>{s}</span>") : Regex.Replace(post.Content, s, $"<span style='color:red;background-color:yellow;font-size: 1.1em;font-weight:700;'>{s}</span>", RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.Multiline); } return(View(post)); } return(RedirectToAction("Index", "Error")); }
public void ResetLucene() { LuceneHelper.DeleteIndex(); UpdateLucene(); }