static void BuildIndex(CodeIndexConfiguration config, bool triggerMerge, bool applyAllDeletes, List <Document> documents, bool needFlush, ILog log) { log?.Info($"Build index start, documents count {documents.Count}"); LucenePool.BuildIndex(config.LuceneIndexForHint, triggerMerge, applyAllDeletes, documents, needFlush); LucenePool.SaveResultsAndClearLucenePool(config.LuceneIndexForHint); log?.Info($"Build index finished"); }
static void UpdateHintWordsAndSaveIndex(CodeIndexConfiguration config, string[] words, ILog log, int batchSize = -1, bool needSaveIndex = true) { var totalUpdate = 0; log?.Info($"Update hint index start, words count {words.Length}"); foreach (var word in words) { var document = new Document { new StringField(nameof(CodeWord.Word), word, Field.Store.YES), new StringField(nameof(CodeWord.WordLower), word.ToLowerInvariant(), Field.Store.YES) }; LucenePool.UpdateIndex(config.LuceneIndexForHint, new Lucene.Net.Index.Term(nameof(CodeWord.Word), word), document); totalUpdate++; if (needSaveIndex && batchSize > 0 && totalUpdate > batchSize) { totalUpdate = 0; LucenePool.SaveResultsAndClearLucenePool(config.LuceneIndexForHint); } } if (needSaveIndex && batchSize > 0 && totalUpdate > 0) { LucenePool.SaveResultsAndClearLucenePool(config.LuceneIndexForHint); } log?.Info($"Update hint index finished"); }
public static void DeleteIndex(string luceneIndex, params Term[] terms) { luceneIndex.RequireNotNullOrEmpty(nameof(luceneIndex)); terms.RequireContainsElement(nameof(terms)); LucenePool.DeleteIndex(luceneIndex, terms); }
public static void DeleteIndex(string luceneIndex, params Query[] searchQueries) { luceneIndex.RequireNotNullOrEmpty(nameof(luceneIndex)); searchQueries.RequireContainsElement(nameof(searchQueries)); LucenePool.DeleteIndex(luceneIndex, searchQueries); }
public static void UpdateIndex(string luceneIndex, Term term, Document document) { luceneIndex.RequireNotNullOrEmpty(nameof(luceneIndex)); term.RequireNotNull(nameof(term)); document.RequireNotNull(nameof(document)); LucenePool.UpdateIndex(luceneIndex, term, document); }
public static void DeleteAllIndex(CodeIndexConfiguration config) { config.RequireNotNull(nameof(config)); if (IndexExists(config.LuceneIndexForCode)) { LucenePool.DeleteAllIndex(config.LuceneIndexForCode); } if (IndexExists(config.LuceneIndexForHint)) { LucenePool.DeleteAllIndex(config.LuceneIndexForHint); } }
public static List <(string FilePath, DateTime LastWriteTimeUtc)> GetAllIndexedCodeSource(string luceneIndex) { luceneIndex.RequireNotNullOrEmpty(nameof(luceneIndex)); return(LucenePool.GetAllIndexedCodeSource(luceneIndex)); }