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))); }
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()); }
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 }); } } }
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); }