public TextIndexContent(IndexWriter indexWriter, IndexState indexState, Guid id)
        {
            this.indexWriter = indexWriter;
            this.indexState  = indexState;

            this.id = id;
        }
        public static bool TryGetId(int docId, Scope scope, IndexReader reader, IndexState indexState, out Guid result)
        {
            result = Guid.Empty;

            if (!indexState.TryGet(docId, out var draft, out var published))
            {
                return(false);
            }

            if (scope == Scope.Draft && draft != 1)
            {
                return(false);
            }

            if (scope == Scope.Published && published != 1)
            {
                return(false);
            }

            var document = reader.Document(docId);

            var idString = document.Get(MetaId);

            if (!Guid.TryParse(idString, out result))
            {
                return(false);
            }

            return(true);
        }
        public static bool TryGetId(int docId, Scope scope, IIndex index, IndexState indexState, out Guid result)
        {
            result = Guid.Empty;

            indexState.Get(docId, out var draft, out var published);

            if (scope == Scope.Draft && !draft)
            {
                return(false);
            }

            if (scope == Scope.Published && !published)
            {
                return(false);
            }

            var document = index.Searcher?.Doc(docId);

            if (document != null)
            {
                var idString = document.Get(MetaId);

                if (!Guid.TryParse(idString, out result))
                {
                    return(false);
                }
            }

            return(true);
        }
        public TextIndexContent(IIndex index, IndexState indexState, Guid id)
        {
            this.index      = index;
            this.indexState = indexState;

            this.id = id;
        }
Beispiel #5
0
 private void OpenReader()
 {
     indexReader?.Dispose();
     indexReader   = indexWriter.GetReader(true);
     indexSearcher = new IndexSearcher(indexReader);
     indexState    = new IndexState(indexReader, indexWriter);
 }
Beispiel #6
0
        protected override async Task OnActivateAsync(Guid key)
        {
            directory = new DirectoryInfo(Path.Combine(Path.GetTempPath(), $"Index_{key}"));

            await assetStore.DownloadAsync(directory);

            var config = new IndexWriterConfig(Version, Analyzer)
            {
                IndexDeletionPolicy = snapshotter
            };

            indexWriter = new IndexWriter(FSDirectory.Open(directory), config);

            if (indexWriter.NumDocs > 0)
            {
                OpenReader();
            }
            else
            {
                indexState = new IndexState(indexReader, indexWriter);
            }
        }
        protected override async Task OnActivateAsync(Guid key)
        {
            index = await indexManager.AcquireAsync(key);

            indexState = new IndexState(index);
        }