Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different classes between filters and return document #8186

Open
imperugo opened this issue May 12, 2024 · 3 comments
Open

Different classes between filters and return document #8186

imperugo opened this issue May 12, 2024 · 3 comments
Labels
8.x Relates to 8.x client version Area: Generator Category: Feature

Comments

@imperugo
Copy link

imperugo commented May 12, 2024

Is your feature request related to a problem? Please describe.
In a scenario when you have to read partially the document (a projection) would be nice to have different classes for the query and for the result.
This is absolutely helpful when you use a class that uses the required keyword for some properties, here an example

internal sealed class SampleSearchDocument : SearchDocumentBase<string>
{
    public required Guid Property1 { get; set; }
    public string? Property2 { get; set; }
    public required DateTime Property3 { get; set; }
    public required int Property4 { get; set; }
}

the projection object could be something like

internal sealed class ProjectionSearchDocument
{
    public required Guid Property1 { get; set; }
}

With that scenario and SourceFilter is not possible because the deserialization process says that some required fields are missing (Property3 and Property4 in this example).

Describe the solution you'd like

elasticSearchClient.SearchAsync<SampleSearchDocument, ProjectionSearchDocument>(.....)

Additional context
I'm using a custom serilization class that uses System.Text.Json with source generators

@silmer
Copy link

silmer commented May 15, 2024

Agreed! I'm new to Elastic Search myself, but it actually looks like a variant of this feature was available in a previous version based on this thread: https://stackoverflow.com/questions/66143051/elasticsearch-mapping-dto-after-source-filtering-in-net (SearchDescriptor no longer seems to exist in a form where this works the new .NET library).

@flobernd
Copy link
Member

@imperugo @silmer Hi there!

This topic came up a few weeks ago (#8074) in a slightly more complex context, but it essentially boils down to the same feature request.

I already put this item on my roadmap 🙂

@flobernd flobernd added 8.x Relates to 8.x client version Area: Generator labels May 17, 2024
@imperugo
Copy link
Author

Hi @flobernd thanks for the feedback. Do you know if there is any workaround to reach the result in the meantime you implement the correct solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8.x Relates to 8.x client version Area: Generator Category: Feature
Projects
None yet
Development

No branches or pull requests

3 participants