rclabo commented on a change in pull request #475:
URL: https://github.com/apache/lucenenet/pull/475#discussion_r625131864
##########
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:
I think TMutableValue is more clear since the T passed must inherit from
MutableValue. But if you feel strongly about it I can change it.
--
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]