コード例 #1
0
 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");
 }
コード例 #2
0
        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");
        }
コード例 #3
0
        public static void DeleteIndex(string luceneIndex, params Term[] terms)
        {
            luceneIndex.RequireNotNullOrEmpty(nameof(luceneIndex));
            terms.RequireContainsElement(nameof(terms));

            LucenePool.DeleteIndex(luceneIndex, terms);
        }
コード例 #4
0
        public static void DeleteIndex(string luceneIndex, params Query[] searchQueries)
        {
            luceneIndex.RequireNotNullOrEmpty(nameof(luceneIndex));
            searchQueries.RequireContainsElement(nameof(searchQueries));

            LucenePool.DeleteIndex(luceneIndex, searchQueries);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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);
            }
        }
コード例 #7
0
 public static List <(string FilePath, DateTime LastWriteTimeUtc)> GetAllIndexedCodeSource(string luceneIndex)
 {
     luceneIndex.RequireNotNullOrEmpty(nameof(luceneIndex));
     return(LucenePool.GetAllIndexedCodeSource(luceneIndex));
 }