Class Filter
Abstract base class for restricting which documents may be returned during searching.
Inheritance
Inherited Members
Namespace: Lucene.Net.Search
Assembly: Lucene.Net.dll
Syntax
public abstract class Filter
Methods
| Improve this Doc View SourceGetDocIdSet(AtomicReaderContext, IBits)
Creates a DocIdSet enumerating the documents that should be
permitted in search results. NOTE: null
can be
returned if no documents are accepted by this Filter.
Note: this method will be called once per segment in the index during searching. The returned DocIdSet must refer to document IDs for that segment, not for the top-level reader.
Declaration
public abstract DocIdSet GetDocIdSet(AtomicReaderContext context, IBits acceptDocs)
Parameters
Type | Name | Description |
---|---|---|
AtomicReaderContext | context | a AtomicReaderContext instance opened on the index currently searched on. Note, it is likely that the provided reader info does not represent the whole underlying index i.e. if the index has more than one segment the given reader only represents a single segment. The provided context is always an atomic context, so you can call Fields on the context's reader, for example. |
IBits | acceptDocs | IBits that represent the allowable docs to match (typically deleted docs but possibly filtering other documents) |
Returns
Type | Description |
---|---|
DocIdSet | A DocIdSet that provides the documents which should be permitted or
prohibited in search results. NOTE: |
NewAnonymous(Func<AtomicReaderContext, IBits, DocIdSet>)
Creates a new instance with the ability to specify the body of the GetDocIdSet(AtomicReaderContext, IBits)
method through the getDocIdSet
parameter.
Simple example:
var filter = Filter.NewAnonymous(getDocIdSet: (context, acceptDocs) =>
{
if (acceptDocs is null) acceptDocs = new Bits.MatchAllBits(5);
OpenBitSet bitset = new OpenBitSet(5);
if (acceptDocs.Get(1)) bitset.Set(1);
if (acceptDocs.Get(3)) bitset.Set(3);
return new DocIdBitSet(bitset);
});
LUCENENET specific
Declaration
public static Filter NewAnonymous(Func<AtomicReaderContext, IBits, DocIdSet> getDocIdSet)
Parameters
Type | Name | Description |
---|---|---|
System.Func<AtomicReaderContext, IBits, DocIdSet> | getDocIdSet | A delegate method that represents (is called by) the GetDocIdSet(AtomicReaderContext, IBits) method. It accepts a AtomicReaderContext context and a IBits acceptDocs and returns the DocIdSet for this filter. |
Returns
Type | Description |
---|---|
Filter |