Example #1
0
        public Searcher(string mainFolder, string taxonomyFolder, string thumbsFolder)
        {
            MaxResultCount = 50;
            mainSearchManager = new SearchManager(FSDirectory.open(new java.io.File(mainFolder)));
            taxonomyReader = new DirectoryTaxonomyReader(FSDirectory.open(new java.io.File(taxonomyFolder)));

            analyzer = FindAPhotoAnalyzers.ForSearching();
            parser = new MultiFieldQueryParser(FieldName.DefaultSearchFields, analyzer);
            parser.setAllowLeadingWildcard(true);

            thumbSearchManager = new SearchManager(FSDirectory.open(new java.io.File(thumbsFolder)));

            using (var wrapper = mainSearchManager.Wrapper())
            {
                indexPreferences = new IndexPreferences(wrapper.IndexSearcher);
            }
        }
        public ThumbnailIndexer(IndexPreferences indexPreferences)
        {
            this.indexPreferences = indexPreferences;

            if (!System.IO.Directory.Exists(Preferences.Instance.ThumbIndexFolder))
            {
                logger.Info("Creating thumbs folder: '{0}'", Preferences.Instance.ThumbIndexFolder);
                System.IO.Directory.CreateDirectory(Preferences.Instance.ThumbIndexFolder);
            }

            var config = new IndexWriterConfig(FindAPhotoAnalyzers.IndexVersion, FindAPhotoAnalyzers.ForIndexing());
            writer = new IndexWriter(
                FSDirectory.open(new java.io.File(Preferences.Instance.ThumbIndexFolder)),
                config);
            writer.commit();

            searchManager = new SearchManager(writer.getDirectory());

            tasks.Add(Task.Run(DequeueFiles));
            tasks.Add(Task.Run(DequeueFiles));
            tasks.Add(Task.Run(CommitTask));
        }
        public DocumentIndexer()
        {
            if (!System.IO.Directory.Exists(Preferences.Instance.MainIndexFolder))
            {
                logger.Info("Creating main index folder: '{0}'", Preferences.Instance.MainIndexFolder);
                System.IO.Directory.CreateDirectory(Preferences.Instance.MainIndexFolder);
            }
            else
            {
                logger.Info("Updating index at '{0}'", Preferences.Instance.MainIndexFolder);
            }

            var config = new IndexWriterConfig(FindAPhotoAnalyzers.IndexVersion, FindAPhotoAnalyzers.ForIndexing());
            mainWriter = new IndexWriter(
                FSDirectory.open(new java.io.File(Preferences.Instance.MainIndexFolder)),
                config);
            taxonomyWriter = new DirectoryTaxonomyWriter(
                FSDirectory.open(new java.io.File(Preferences.Instance.FacetIndexFolder)),
                IndexWriterConfig.OpenMode.CREATE_OR_APPEND);

            indexPreferences = new IndexPreferences(mainWriter);
            thumbnailIndexer = new ThumbnailIndexer(indexPreferences);
            startTime = DateTime.Now;
        }