Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
 public void SetDefaultIndex(string stemmerName)
 {
     SearchEngine.SetDefaultIndex(stemmerName);
 }