 | IFulltextQueryTDocumentGroupByTKey Method (ExpressionFuncTDocument, TKey, Int32) |
Group the results of this query by the given key and return a given amount of results per group. Supported with Sphinx 2.2.1 and above.
Namespace:
SphinxConnector.FluentApi
Assembly:
SphinxConnector (in SphinxConnector.dll) Version: 5.4.1
SyntaxIFulltextQuery<TDocument> GroupBy<TKey>(
Expression<Func<TDocument, TKey>> keySelector,
int maxResultsPerGroup
)
Function GroupBy(Of TKey) (
keySelector As Expression(Of Func(Of TDocument, TKey)),
maxResultsPerGroup As Integer
) As IFulltextQuery(Of TDocument)
Parameters
- keySelector
- Type: System.Linq.ExpressionsExpressionFuncTDocument, TKey
A function to extract the key from a document. - maxResultsPerGroup
- Type: SystemInt32
The (maximum) number of results to return per group.
Type Parameters
- TKey
- The type of the key returned by the function that is represented by keySelector.
Return Value
Type:
IFulltextQueryTDocumentThe current instance.
Exceptions
Examplesusing (IFulltextSession fulltextSession = fulltextStore.StartSession())
{
var results = fulltextSession.Query<Product>().
Match("a product").
GroupBy(p => p.CategoryId, 5).
Select(p => new
{
p.CategoryId,
p.Name,
p.Price
}).ToList();
}
See Also