Skip to content

Commit 522d05c

Browse files
committed
Add XML doc comments to GroupingSearch
1 parent ef891eb commit 522d05c

1 file changed

Lines changed: 118 additions & 1 deletion

File tree

src/Lucene.Net.Grouping/GroupingSearch.cs

Lines changed: 118 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,37 +30,108 @@ namespace Lucene.Net.Search.Grouping
3030

3131
/// <summary>
3232
/// Convenience class to perform grouping in a non distributed environment.
33+
/// <para />
34+
/// LUCENENET Note: This class has been significantly changed from Lucene.
35+
/// The previous implementation combined field, function, and doc block grouping
36+
/// into one large class and required the use of Java's generic type erasure and
37+
/// wildcard generics to handle the different types of grouping. This implementation
38+
/// splits the different types of grouping into separate classes and uses a common
39+
/// base class to handle the common functionality.
40+
/// <para />
41+
/// This class contains three static factory methods to create instances of the
42+
/// different types of grouping:
43+
/// <list type="bullet">
44+
/// <item>
45+
/// <description>
46+
/// <see cref="ByField(string)"/> - Constructs a <see cref="FieldGroupingSearch" /> instance
47+
/// that groups documents by index terms using the <see cref="FieldCache"/>.
48+
/// The group field can only have one token per document. This means that the field must not be analysed.
49+
/// </description>
50+
/// </item>
51+
/// <item>
52+
/// <description>
53+
/// <see cref="ByFunction{TMutableValue}(ValueSource, IDictionary)"/> - Constructs a <see cref="FunctionGroupingSearch{TMutableValue}"/> instance
54+
/// that groups documents by function using a <see cref="ValueSource"/> instance.
55+
/// </description>
56+
/// </item>
57+
/// <item>
58+
/// <description>
59+
/// <see cref="ByDocBlock{TGroupValue}(Filter)"/> - Constructs a <see cref="DocBlockGroupingSearch{TGroupValue}"/> instance
60+
/// that groups documents by doc block. This method can only be used when documents belonging in a group are indexed in one block.
61+
/// </description>
62+
/// </item>
63+
/// </list>
64+
/// These types each return a type that behaves like the original GroupingSearch class,
65+
/// but specific to the type of grouping being performed.
66+
/// <para />
67+
/// It is not required to use these methods; you can also create instances of the
68+
/// specific grouping classes directly which will be closer to the original Lucene
69+
/// usage.
70+
/// <para />
3371
/// @lucene.experimental
3472
/// </summary>
73+
/// <seealso cref="FieldGroupingSearch"/>
74+
/// <seealso cref="FunctionGroupingSearch{TMutableValue}"/>
75+
/// <seealso cref="DocBlockGroupingSearch{TGroupValue}"/>
3576
public static class GroupingSearch
3677
{
78+
/// <summary>
79+
/// Constructs a <see cref="FieldGroupingSearch"/> instance that groups documents by index terms using the <see cref="FieldCache"/>.
80+
/// The group field can only have one token per document. This means that the field must not be analysed.
81+
/// </summary>
82+
/// <param name="groupField">The name of the field to group by.</param>
83+
/// <returns>A <see cref="FieldGroupingSearch"/> instance.</returns>
3784
public static FieldGroupingSearch ByField(string groupField)
3885
{
3986
return new FieldGroupingSearch(groupField);
4087
}
4188

89+
/// <summary>
90+
/// Constructs a <see cref="FunctionGroupingSearch{TMutableValue}"/> instance that groups documents by function using a <see cref="ValueSource"/> instance.
91+
/// </summary>
92+
/// <param name="groupFunction">The function to group by specified as <see cref="ValueSource"/></param>
93+
/// <param name="valueSourceContext">The context of the specified groupFunction</param>
94+
/// <typeparam name="TMutableValue">The type of the mutable value</typeparam>
95+
/// <returns>A <see cref="FunctionGroupingSearch{TMutableValue}"/> instance.</returns>
4296
public static FunctionGroupingSearch<TMutableValue> ByFunction<TMutableValue>(ValueSource groupFunction, IDictionary valueSourceContext)
4397
where TMutableValue : MutableValue
4498
{
4599
return new FunctionGroupingSearch<TMutableValue>(groupFunction, valueSourceContext);
46100
}
47101

102+
/// <summary>
103+
/// Constructs a <see cref="DocBlockGroupingSearch{TGroupValue}"/> instance that groups documents by doc block.
104+
/// This method can only be used when documents belonging in a group are indexed in one block.
105+
/// </summary>
106+
/// <param name="groupEndDocs">The filter that marks the last document in all doc blocks</param>
107+
/// <typeparam name="TGroupValue">The type of the group value</typeparam>
108+
/// <returns>A <see cref="DocBlockGroupingSearch{TGroupValue}"/> instance.</returns>
48109
public static DocBlockGroupingSearch<TGroupValue> ByDocBlock<TGroupValue>(Filter groupEndDocs)
49110
{
50111
return new DocBlockGroupingSearch<TGroupValue>(groupEndDocs);
51112
}
52113
}
53114

115+
/// <summary>
116+
/// A grouping search that groups documents by index terms using the <see cref="FieldCache"/>.
117+
/// The group field can only have one token per document. This means that the field must not be analysed.
118+
/// </summary>
119+
/// <seealso cref="GroupingSearch.ByField(string)"/>
54120
public class FieldGroupingSearch : AbstractFieldOrFunctionGroupingSearch<BytesRef>
55121
{
56122
private readonly string groupField;
57123
private int initialSize = 128;
58124

125+
/// <summary>
126+
/// Constructs a <see cref="FieldGroupingSearch"/> instance that groups documents by index terms using the <see cref="FieldCache"/>.
127+
/// </summary>
128+
/// <param name="groupField">The name of the field to group by.</param>
59129
public FieldGroupingSearch(string groupField)
60130
{
61131
this.groupField = groupField;
62132
}
63133

134+
/// <inheritdoc cref="AbstractGroupingSearch{T}.Search(IndexSearcher,Filter,Query,int,int)"/>
64135
public override TopGroups<BytesRef> Search(IndexSearcher searcher, Filter filter, Query query, int groupOffset, int groupLimit)
65136
{
66137
int topN = groupOffset + groupLimit;
@@ -179,7 +250,6 @@ public override TopGroups<BytesRef> Search(IndexSearcher searcher, Filter filter
179250
}
180251
}
181252

182-
183253
/// <summary>
184254
/// Sets the initial size of some internal used data structures.
185255
/// This prevents growing data structures many times. This can improve the performance of the grouping at the cost of
@@ -199,18 +269,29 @@ public virtual FieldGroupingSearch SetInitialSize(int initialSize)
199269
}
200270
}
201271

272+
/// <summary>
273+
/// A grouping search that groups documents by function using a <see cref="ValueSource"/> instance.
274+
/// </summary>
275+
/// <typeparam name="T">The type of the mutable value</typeparam>
276+
/// <seealso cref="GroupingSearch.ByFunction{TMutableValue}(ValueSource, IDictionary)"/>
202277
public class FunctionGroupingSearch<T> : AbstractFieldOrFunctionGroupingSearch<T>
203278
where T : MutableValue
204279
{
205280
private readonly ValueSource groupFunction;
206281
private readonly IDictionary /* Map<?, ?> */ valueSourceContext;
207282

283+
/// <summary>
284+
/// Constructs a <see cref="FunctionGroupingSearch{T}"/> instance that groups documents by function using a <see cref="ValueSource"/> instance.
285+
/// </summary>
286+
/// <param name="groupFunction">The function to group by specified as <see cref="ValueSource"/></param>
287+
/// <param name="valueSourceContext">The context of the specified groupFunction</param>
208288
public FunctionGroupingSearch(ValueSource groupFunction, IDictionary /* Map<?, ?> */ valueSourceContext)
209289
{
210290
this.groupFunction = groupFunction;
211291
this.valueSourceContext = valueSourceContext;
212292
}
213293

294+
/// <inheritdoc cref="AbstractGroupingSearch{T}.Search(IndexSearcher,Filter,Query,int,int)"/>
214295
public override TopGroups<T> Search(IndexSearcher searcher, Filter filter, Query query, int groupOffset, int groupLimit)
215296
{
216297
int topN = groupOffset + groupLimit;
@@ -332,15 +413,26 @@ public override TopGroups<T> Search(IndexSearcher searcher, Filter filter, Query
332413
}
333414
}
334415

416+
/// <summary>
417+
/// A grouping search that groups documents by doc block.
418+
/// This class can only be used when documents belonging in a group are indexed in one block.
419+
/// </summary>
420+
/// <typeparam name="T">The type of the group value</typeparam>
335421
public class DocBlockGroupingSearch<T> : AbstractGroupingSearch<T>
336422
{
337423
private readonly Filter groupEndDocs;
338424

425+
/// <summary>
426+
/// Constructs a <see cref="DocBlockGroupingSearch{T}"/> instance that groups documents by doc block.
427+
/// This class can only be used when documents belonging in a group are indexed in one block.
428+
/// </summary>
429+
/// <param name="groupEndDocs">The filter that marks the last document in all doc blocks</param>
339430
public DocBlockGroupingSearch(Filter groupEndDocs)
340431
{
341432
this.groupEndDocs = groupEndDocs;
342433
}
343434

435+
/// <inheritdoc cref="AbstractGroupingSearch{T}.Search(IndexSearcher,Filter,Query,int,int)"/>
344436
public override TopGroups<T> Search(IndexSearcher searcher, Filter filter, Query query, int groupOffset, int groupLimit)
345437
{
346438
int topN = groupOffset + groupLimit;
@@ -351,6 +443,10 @@ public override TopGroups<T> Search(IndexSearcher searcher, Filter filter, Query
351443
}
352444
}
353445

446+
/// <summary>
447+
/// Abstract base class for grouping search implementations that groups documents by index terms or function.
448+
/// </summary>
449+
/// <typeparam name="T">The type of the group value</typeparam>
354450
public abstract class AbstractFieldOrFunctionGroupingSearch<T> : AbstractGroupingSearch<T>
355451
{
356452
// LUCENENET: Converted to protected properties
@@ -469,6 +565,10 @@ public virtual IBits GetAllGroupHeads()
469565
}
470566
}
471567

568+
/// <summary>
569+
/// Abstract base class for grouping search implementations.
570+
/// </summary>
571+
/// <typeparam name="T">The type of the group value</typeparam>
472572
public abstract class AbstractGroupingSearch<T>
473573
{
474574
// LUCENENET: Converted to protected properties
@@ -480,11 +580,28 @@ public abstract class AbstractGroupingSearch<T>
480580
protected bool FillSortFields { get; private set; }
481581
protected bool IncludeScores { get; private set; } = true;
482582

583+
/// <summary>
584+
/// Executes a grouped search. Both the first pass and second pass are executed on the specified searcher.
585+
/// </summary>
586+
/// <param name="searcher">The <see cref="IndexSearcher"/> instance to execute the grouped search on.</param>
587+
/// <param name="query">The query to execute with the grouping</param>
588+
/// <param name="groupOffset">The group offset</param>
589+
/// <param name="groupLimit">The number of groups to return from the specified group offset</param>
590+
/// <returns>the grouped result as a <see cref="TopGroups"/> instance</returns>
483591
public TopGroups<T> Search(IndexSearcher searcher, Query query, int groupOffset, int groupLimit)
484592
{
485593
return Search(searcher, null, query, groupOffset, groupLimit);
486594
}
487595

596+
/// <summary>
597+
/// Executes a grouped search. Both the first pass and second pass are executed on the specified searcher.
598+
/// </summary>
599+
/// <param name="searcher">The <see cref="IndexSearcher"/> instance to execute the grouped search on.</param>
600+
/// <param name="filter">The filter to execute with the grouping</param>
601+
/// <param name="query">The query to execute with the grouping</param>
602+
/// <param name="groupOffset">The group offset</param>
603+
/// <param name="groupLimit">The number of groups to return from the specified group offset</param>
604+
/// <returns>the grouped result as a <see cref="TopGroups"/> instance</returns>
488605
public abstract TopGroups<T> Search(IndexSearcher searcher, Filter filter, Query query, int groupOffset, int groupLimit);
489606

490607
/// <summary>

0 commit comments

Comments
 (0)