Пример #1
0
        private IEnumerable <DocumentScore> GetDocIdsByPrefix(Term term, FieldReader reader)
        {
            var terms = reader.GetTokens(term.Token).Select(token => new Term {
                Field = term.Field, Token = token
            }).ToList();

            return(terms.SelectMany(t => GetDocIdsExact(t, reader)));
        }
Пример #2
0
        public IEnumerable <TokenInfo> GetAllTokens(string field)
        {
            int fieldId;

            if (_fieldIndex.TryGetValue(field, out fieldId))
            {
                var f = FieldReader.Load(Path.Combine(_directory, fieldId + ".fld"));
                return(f.GetAllTokens());
            }
            return(Enumerable.Empty <TokenInfo>().ToList());
        }
Пример #3
0
        private IEnumerable <DocumentScore> GetDocIdsExact(Term term, FieldReader reader)
        {
            var postings = reader.GetPostings(term.Token);

            if (postings != null)
            {
                foreach (var posting in postings)
                {
                    yield return(new DocumentScore {
                        DocId = posting.Key, Value = posting.Value.Count
                    });
                }
            }
        }
Пример #4
0
        private FieldReader GetReader(string field)
        {
            int fieldId;

            if (_fieldIndex.TryGetValue(field, out fieldId))
            {
                FieldReader reader;
                if (!_fieldReaders.TryGetValue(field, out reader))
                {
                    reader = FieldReader.Load(Path.Combine(_directory, fieldId + ".fld"));
                    _fieldReaders.Add(field, reader);
                }
                return(reader);
            }
            return(null);
        }