Ejemplo n.º 1
0
        public Task <List <Guid> > SearchAsync(string queryText, SearchContext context)
        {
            var result = new List <Guid>();

            if (!string.IsNullOrWhiteSpace(queryText))
            {
                var query = BuildQuery(queryText, context);

                if (indexReader == null && indexWriter.NumDocs > 0)
                {
                    OpenReader();
                }

                if (indexReader != null)
                {
                    var found = new HashSet <Guid>();

                    var hits = indexSearcher.Search(query, MaxResults).ScoreDocs;

                    foreach (var hit in hits)
                    {
                        if (TextIndexContent.TryGetId(hit.Doc, context.Scope, indexReader, indexState, out var id))
                        {
                            if (found.Add(id))
                            {
                                result.Add(id);
                            }
                        }
                    }
                }
            }

            return(Task.FromResult(result.ToList()));
        }
Ejemplo n.º 2
0
        public Task <bool> CopyAsync(Guid id, bool fromDraft)
        {
            var content = new TextIndexContent(indexWriter, indexState, id);

            content.Copy(fromDraft);

            return(TryFlushAsync());
        }
Ejemplo n.º 3
0
        private Task <bool> IndexInternalAsync(Update update)
        {
            var content = new TextIndexContent(indexWriter, indexState, update.Id);

            content.Index(update.Data, update.OnlyDraft);

            return(TryFlushAsync());
        }
Ejemplo n.º 4
0
        public Task <bool> DeleteAsync(Guid id)
        {
            var content = new TextIndexContent(indexWriter, indexState, id);

            content.Delete();

            return(TryFlushAsync());
        }
Ejemplo n.º 5
0
        public Task IndexAsync(Guid id, J <IndexData> data, bool onlyDraft)
        {
            var content = new TextIndexContent(indexWriter, indexSearcher, indexState, id);

            content.Index(data.Value.Data, onlyDraft);

            return(TryFlushAsync());
        }
Ejemplo n.º 6
0
        public Task <bool> DeleteAsync(Guid id)
        {
            var content = new TextIndexContent(index, indexState, id);

            content.Delete();

            return(TryCommitAsync());
        }
Ejemplo n.º 7
0
        public Task <bool> IndexAsync(Update update)
        {
            var content = new TextIndexContent(index, indexState, update.Id);

            content.Index(update.Text, update.OnlyDraft);

            return(TryCommitAsync());
        }