Skip to content

Commit

Permalink
fix: or-2334 allow chaining for must not on zoek query
Browse files Browse the repository at this point in the history
  • Loading branch information
emalfroy committed Dec 13, 2024
1 parent 42b0616 commit a3fd966
Showing 1 changed file with 19 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,40 +31,37 @@ private static Func<QueryContainerDescriptor<VerenigingZoekDocument>, QueryConta
);
}

private static QueryContainer BeVerwijderd(QueryContainerDescriptor<VerenigingZoekDocument> shouldDescriptor)
{
return shouldDescriptor
.Term(termDescriptor
=> termDescriptor
.Field(document => document.IsVerwijderd)
.Value(true));
}

private static QueryContainer BeDubbel(QueryContainerDescriptor<VerenigingZoekDocument> shouldDescriptor)
{
return shouldDescriptor
.Term(termDescriptor
=> termDescriptor
.Field(document => document.IsDubbel)
.Value(true));
}

public async Task<ISearchResponse<VerenigingZoekDocument>> ExecuteAsync(BeheerVerenigingenZoekFilter filter, CancellationToken cancellationToken)
=> await _client.SearchAsync<VerenigingZoekDocument>(
s => s
.From(filter.PaginationQueryParams.Offset)
.Size(filter.PaginationQueryParams.Limit)
.ParseSort(filter.Sort, DefaultSort, _typeMapping)
.Query(query => query
.Bool(boolQueryDescriptor =>
boolQueryDescriptor.Must(MatchWithQuery(filter.Query))
.MustNot(BeVerwijderd)
.MustNot(BeDubbel)
.Bool(boolQueryDescriptor => boolQueryDescriptor
.Must(MatchWithQuery(filter.Query))
.MustNot(BeVerwijderd(), BeDubbel())
)
)
.TrackTotalHits(),
cancellationToken
);

private static Func<QueryContainerDescriptor<VerenigingZoekDocument>, QueryContainer> BeVerwijderd()
{
return q => q
.Term(t => t
.Field(f => f.IsVerwijderd)
.Value(true));
}

private static Func<QueryContainerDescriptor<VerenigingZoekDocument>, QueryContainer> BeDubbel()
{
return q => q
.Term(t => t
.Field(f => f.IsDubbel)
.Value(true));
}
}

public record BeheerVerenigingenZoekFilter
Expand Down

0 comments on commit a3fd966

Please sign in to comment.