public void AddOrOpenIndex(string stemmerName) { Check.DoRequireArgumentNotNull(stemmerName, nameof(stemmerName)); Log.InfoFormat($"Adding index {0}", stemmerName); Check.DoCheckArgument(MultiIndex.GetIndex(stemmerName) == null, () => $"Index {stemmerName} is already active"); var info = SearchEngine.AddOrOpenSnowballIndex(stemmerName); SearchEngine.RebuildIndex(stemmerName, Storage.GetAll(), Storage.CountAll()); info.LuceneIndex.Commit(); }
public void OpenOrCreateIndexes(IEnumerable <string> stemmerNames, Action <double> progressReporter = null) { Check.DoRequireArgumentNotNull(stemmerNames, nameof(stemmerNames)); var languageNames = stemmerNames.ToCaseInsensitiveSet(); var allSupportedLangs = LuceneIndex.GetAvailableSnowballStemmers().ToCaseInsensitiveSet(); var unknownLangs = string.Join(",", languageNames.Where(n => !allSupportedLangs.Contains(n))); if (!string.IsNullOrEmpty(unknownLangs)) { throw new FulltextException($"The following configured languages are not supported: {unknownLangs}"); } var newIndexes = new List <IndexInformation>(); foreach (var stemmerName in stemmerNames) { var info = SearchEngine.AddOrOpenSnowballIndex(stemmerName); if (info.IsNew) { newIndexes.Add(info); } } if (languageNames.Count > 1) { SearchEngine.SetDefaultIndex(stemmerNames.First()); } if (newIndexes.Count > 0) { RebuildIndexes(newIndexes.Select(x => x.Name).ToArray(), progressReporter); } }