NightOwl888 commented on a change in pull request #475:
URL: https://github.com/apache/lucenenet/pull/475#discussion_r625189817



##########
File path: src/Lucene.Net.Grouping/GroupingSearch.cs
##########
@@ -161,86 +196,261 @@ public virtual ITopGroups<object> Search(IndexSearcher 
searcher, Filter filter,
         }
 
         /// <summary>
-        /// Executes a grouped search. Both the first pass and second pass are 
executed on the specified searcher.
+        /// Executes a grouped search base on the field specified via the 
constructor. Both the first pass
+        /// and second pass are executed on the specified searcher.
+        /// </summary>
+        /// <param name="searcher">The <see cref="IndexSearcher"/> instance to 
execute the grouped search on.</param>
+        /// <param name="query">The query to execute with the grouping</param>
+        /// <param name="groupOffset">The group offset</param>
+        /// <param name="groupLimit">The number of groups to return from the 
specified group offset</param>
+        /// <returns>the grouped result as a <see cref="ITopGroups{Object}"/> 
instance</returns>
+        /// <exception cref="IOException">If any I/O related errors 
occur</exception>
+        // LUCENENET additional method signature. Makes searching by field 
easier due to concrete return type
+        public virtual ITopGroups<BytesRef> SearchByField(IndexSearcher 
searcher, Query query, int groupOffset, int groupLimit)
+        {
+            return GroupByField<BytesRef>(searcher, null, query, groupOffset, 
groupLimit);
+        }
+
+
+        /// <summary>
+        /// Executes a grouped search base on the field specified via the 
constructor. Both the first pass
+        /// and second pass are executed on the specified searcher.
         /// </summary>
-        /// <typeparam name="TGroupValue">The expected return type of the 
search.</typeparam>
         /// <param name="searcher">The <see cref="IndexSearcher"/> instance to 
execute the grouped search on.</param>
         /// <param name="filter">The filter to execute with the 
grouping</param>
         /// <param name="query">The query to execute with the grouping</param>
         /// <param name="groupOffset">The group offset</param>
         /// <param name="groupLimit">The number of groups to return from the 
specified group offset</param>
         /// <returns>the grouped result as a <see cref="ITopGroups{Object}"/> 
instance</returns>
         /// <exception cref="IOException">If any I/O related errors 
occur</exception>
-        public virtual ITopGroups<TGroupValue> 
Search<TGroupValue>(IndexSearcher searcher, Filter filter, Query query, int 
groupOffset, int groupLimit)
+        // LUCENENET additional method signature. Makes searching by field 
easier due to concrete return type
+        public virtual ITopGroups<BytesRef> SearchByField(IndexSearcher 
searcher, Filter filter, Query query, int groupOffset, int groupLimit)
         {
-            if (groupField != null || groupFunction != null)
+            if (groupField is null)
             {
-                return GroupByFieldOrFunction<TGroupValue>(searcher, filter, 
query, groupOffset, groupLimit);
+                throw IllegalStateException.Create("Must use constructor to 
set pass a non null value for groupField.");
             }
-            else if (groupEndDocs != null)
+
+            if (groupFunction != null)
             {
-                return GroupByDocBlock<TGroupValue>(searcher, filter, query, 
groupOffset, groupLimit);
+                throw IllegalStateException.Create("The groupFunction must be 
null.");
             }
-            else
+            return GroupByField<BytesRef>(searcher, filter, query, 
groupOffset, groupLimit);
+        }
+
+        /// <summary>
+        /// Executes a grouped search base on the function specified by a <see 
cref="ValueSource"/> passed via the constructor.
+        /// Both the first pass and second pass are executed on the specified 
searcher.
+        /// </summary>
+        /// <param name="searcher">The <see cref="IndexSearcher"/> instance to 
execute the grouped search on.</param>
+        /// <param name="query">The query to execute with the grouping</param>
+        /// <param name="groupOffset">The group offset</param>
+        /// <param name="groupLimit">The number of groups to return from the 
specified group offset</param>
+        /// <returns>the grouped result as a <see cref="ITopGroups{Object}"/> 
instance</returns>
+        /// <exception cref="IOException">If any I/O related errors 
occur</exception>
+        // LUCENENET additional method signature. Makes searching by function 
easier due to ability to specify type of MutableValue returned.
+        public virtual ITopGroups<TMutableValue> 
SearchByFunction<TMutableValue>(IndexSearcher searcher, Query query, int 
groupOffset, int groupLimit)
+            where TMutableValue : MutableValue
+        {
+            return GroupByFunction<TMutableValue>(searcher, null, query, 
groupOffset, groupLimit);
+        }
+
+        /// <summary>
+        /// Executes a grouped search base on the function specified by a <see 
cref="ValueSource"/> passed via the constructor.
+        /// Both the first pass and second pass are executed on the specified 
searcher.
+        /// </summary>
+        /// <param name="searcher">The <see cref="IndexSearcher"/> instance to 
execute the grouped search on.</param>
+        /// <param name="filter">The filter to execute with the 
grouping</param>
+        /// <param name="query">The query to execute with the grouping</param>
+        /// <param name="groupOffset">The group offset</param>
+        /// <param name="groupLimit">The number of groups to return from the 
specified group offset</param>
+        /// <returns>the grouped result as a <see cref="ITopGroups{Object}"/> 
instance</returns>
+        /// <exception cref="IOException">If any I/O related errors 
occur</exception>
+        // LUCENENET additional method signature. Makes searching by function 
easier due to ability to specify type of MutableValue returned.
+        public virtual ITopGroups<TMutableValue> 
SearchByFunction<TMutableValue>(IndexSearcher searcher, Filter filter, Query 
query, int groupOffset, int groupLimit)
+            where TMutableValue : MutableValue

Review comment:
       What type it is is clear, however, its purpose (that this is the type it 
is grouping on) is not. While we could make this clear by adding a 
[`<typeparam>`](https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/xmldoc/typeparam)
 value in the documentation, I still think that naming the generic parameter 
after its purpose rather than its type is important.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to