Skip to content

Commit

Permalink
Added support for grouping in multisearch requests (#247) (#248)
Browse files Browse the repository at this point in the history
  • Loading branch information
jarto666 authored Sep 30, 2024
1 parent 22f7988 commit 9c2cbb3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/Typesense/SearchParameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ public record MultiSearchParameters : SearchParameters
/// </summary>
[JsonConverter(typeof(VectorQueryJsonConverter)), JsonPropertyName("vector_query")]
public VectorQuery? VectorQuery { get; init; }

[JsonPropertyName("group_by")]
public string GroupBy { get; set; }

[JsonPropertyName("group_limit")]
public int? GroupLimit { get; set; }

[JsonPropertyName("group_missing_values")]
public bool? GroupMissingValues { get; set; }

public MultiSearchParameters(string collection, string text) : base(text)
{
Expand Down Expand Up @@ -459,6 +468,15 @@ public record GroupedSearchParameters : SearchParameters
/// </summary>
[JsonPropertyName("group_limit")]
public int? GroupLimit { get; set; }

/// <summary>
/// Setting this parameter to true will place all documents that have a null value in the group_by field,
/// into a single group. Setting this parameter to false, will cause each document with a null value
/// in the group_by field to not be grouped with other documents.
/// Default: true
/// </summary>
[JsonPropertyName("group_missing_values")]
public bool? GroupMissingValues { get; set; }

public GroupedSearchParameters(
string text,
Expand Down
6 changes: 6 additions & 0 deletions src/Typesense/SearchResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,14 @@ public record MultiSearchResult<T>
[JsonPropertyName("found")]
public int? Found { get; init; }

[JsonPropertyName("found_docs")]
public int? FoundDocs { get; init; }

[JsonPropertyName("hits")]
public IReadOnlyList<Hit<T>>? Hits { get; init; }

[JsonPropertyName("grouped_hits")]
public IReadOnlyList<GroupedHit<T>> GroupedHits { get; init; }

[JsonPropertyName("out_of")]
public int? OutOf { get; init; }
Expand Down

0 comments on commit 9c2cbb3

Please sign in to comment.