Class ToParentBlockJoinCollector
Collects parent document hits for a Lucene.Net.Search.Query containing one more more BlockJoinQuery clauses, sorted by the specified parent Lucene.Net.Search.Sort. Note that this cannot perform arbitrary joins; rather, it requires that all joined documents are indexed as a doc block (using AddDocuments(IEnumerable<IEnumerable<IIndexableField>>, Analyzer) or UpdateDocuments(Term, IEnumerable<IEnumerable<IIndexableField>>, Analyzer). Ie, the join is computed at index time.
The parent Lucene.Net.Search.Sort must only use fields from the parent documents; sorting by field in the child documents is not supported.
You should only use this collector if one or more of the clauses in the query is a ToParentBlockJoinQuery. This collector will find those query clauses and record the matching child documents for the top scoring parent documents.
Multiple joins (star join) and nested joins and a mix of the two are allowed, as long as in all cases the documents corresponding to a single row of each joined parent table were indexed as a doc block.
For the simple star join you can retrieve the Lucene.Net.Search.Grouping.ITopGroups<TGroupValue> instance containing each ToParentBlockJoinQuery's matching child documents for the top parent groups, using GetTopGroups(ToParentBlockJoinQuery, Sort, Int32, Int32, Int32, Boolean). Ie, a single query, which will contain two or more ToParentBlockJoinQuery's as clauses representing the star join, can then retrieve two or more Lucene.Net.Search.Grouping.ITopGroups<TGroupValue> instances.
For nested joins, the query will run correctly (ie, match the right parent and child documents), however, because Lucene.Net.Search.Grouping.TopGroups`1 is currently unable to support nesting (each group is not able to hold another Lucene.Net.Search.Grouping.TopGroups`1), you are only able to retrieve the Lucene.Net.Search.Grouping.TopGroups`1 of the first join. The Lucene.Net.Search.Grouping.TopGroups`1 of the nested joins will not be correct.
See http://lucene.apache.org/core/4_8_0/join/ for a code sample.
Inheritance
Implements
Inherited Members
Namespace: Lucene.Net.Join
Assembly: Lucene.Net.Join.dll
Syntax
public class ToParentBlockJoinCollector : ICollector
Constructors
| Improve this Doc View SourceToParentBlockJoinCollector(Sort, Int32, Boolean, Boolean)
Creates a ToParentBlockJoinCollector. The provided sort
must
not be null. If you pass true trackScores
, all
ToParentBlockQuery instances must not use
None.
Declaration
public ToParentBlockJoinCollector(Sort sort, int numParentHits, bool trackScores, bool trackMaxScore)
Parameters
Type | Name | Description |
---|---|---|
Lucene.Net.Search.Sort | sort | |
System.Int32 | numParentHits | |
System.Boolean | trackScores | |
System.Boolean | trackMaxScore |
Properties
| Improve this Doc View SourceAcceptsDocsOutOfOrder
Declaration
public virtual bool AcceptsDocsOutOfOrder { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
MaxScore
Returns the highest score across all collected parent hits, as long as
trackMaxScores=true
was passed
ToParentBlockJoinCollector(Sort, Int32, Boolean, Boolean) on
construction. Else, this returns System.Single.NaN.
Declaration
public virtual float MaxScore { get; }
Property Value
Type | Description |
---|---|
System.Single |
Methods
| Improve this Doc View SourceCollect(Int32)
Declaration
public virtual void Collect(int parentDoc)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | parentDoc |
GetTopGroups(ToParentBlockJoinQuery, Sort, Int32, Int32, Int32, Boolean)
Returns the Lucene.Net.Search.Grouping.ITopGroups<TGroupValue> for the specified
BlockJoinQuery. The groupValue of each GroupDocs will
be the parent docID for that group.
The number of documents within each group is calculated as minimum of maxDocsPerGroup
and number of matched child documents for that group.
Returns null
if no groups matched.
Declaration
public virtual ITopGroups<int> GetTopGroups(ToParentBlockJoinQuery query, Sort withinGroupSort, int offset, int maxDocsPerGroup, int withinGroupOffset, bool fillSortFields)
Parameters
Type | Name | Description |
---|---|---|
ToParentBlockJoinQuery | query | Search query |
Lucene.Net.Search.Sort | withinGroupSort | Sort criteria within groups |
System.Int32 | offset | Parent docs offset |
System.Int32 | maxDocsPerGroup | Upper bound of documents per group number |
System.Int32 | withinGroupOffset | Offset within each group of child docs |
System.Boolean | fillSortFields | Specifies whether to add sort fields or not |
Returns
Type | Description |
---|---|
Lucene.Net.Search.Grouping.ITopGroups<System.Int32> | Lucene.Net.Search.Grouping.ITopGroups<TGroupValue> for specified query |
Exceptions
Type | Condition |
---|---|
System.IO.IOException | if there is a low-level I/O error |
GetTopGroupsWithAllChildDocs(ToParentBlockJoinQuery, Sort, Int32, Int32, Boolean)
Returns the Lucene.Net.Search.Grouping.TopGroups`1 for the specified BlockJoinQuery. The groupValue of each
GroupDocs will be the parent docID for that group. The number of documents within
each group equals to the total number of matched child documents for that group.
Returns null
if no groups matched.
Declaration
public virtual ITopGroups<int> GetTopGroupsWithAllChildDocs(ToParentBlockJoinQuery query, Sort withinGroupSort, int offset, int withinGroupOffset, bool fillSortFields)
Parameters
Type | Name | Description |
---|---|---|
ToParentBlockJoinQuery | query | Search query |
Lucene.Net.Search.Sort | withinGroupSort | Sort criteria within groups |
System.Int32 | offset | Parent docs offset |
System.Int32 | withinGroupOffset | Offset within each group of child docs |
System.Boolean | fillSortFields | Specifies whether to add sort fields or not |
Returns
Type | Description |
---|---|
Lucene.Net.Search.Grouping.ITopGroups<System.Int32> | Lucene.Net.Search.Grouping.ITopGroups<TGroupValue> for specified query |
Exceptions
Type | Condition |
---|---|
System.IO.IOException | if there is a low-level I/O error |
SetNextReader(AtomicReaderContext)
Declaration
public virtual void SetNextReader(AtomicReaderContext context)
Parameters
Type | Name | Description |
---|---|---|
Lucene.Net.Index.AtomicReaderContext | context |
SetScorer(Scorer)
Declaration
public virtual void SetScorer(Scorer scorer)
Parameters
Type | Name | Description |
---|---|---|
Lucene.Net.Search.Scorer | scorer |