Forum Discussion
Pedro Correa
Jun 03, 2021Brass Contributor
When to use and how to get querying proficiency
Alright, I will try to be short here but anyone let me know if more info is needed. We had this new project started 3 months ago, that was increasing the amount of data it was going inside our Elast...
DerekLegenzoff
Jun 03, 2021Microsoft
Hey Pedro - I'm not quite sure I understand your third question. Are you trying to select a certain field but the data for it isn't being returned? Are you serializing the data and that's when it becomes null?
- Pedro CorreaJun 03, 2021Brass ContributorThat is correct, in the deserialization process the data end up null.
- DerekLegenzoffJun 03, 2021MicrosoftThanks for the clarification. The reason that the data is ending up null is because a decision was made that we want customers to own their data models as a best practice so the in-built data types don't necessarily serialize all fields (you'll run into a similar issue with counts on facets). To get around the issue you're running into, I would recommend mapping the data from the response into classes that you create. You can do this pretty quickly with a package like Mapster: https://github.com/MapsterMapper/Mapster
- Pedro CorreaJun 03, 2021Brass ContributorDerek that sounds very promising, do you have any examples of that? I'm confuse because trough the sdk the only way for me to call the search is to pass a class for it to automatically deserialize the results for me. https://docs.microsoft.com/en-us/dotnet/api/overview/azure/search.documents-readme
so, i'm wondering, how do I control that field mapping conversion myself? Is it trough field mappings with annotations? like the mapster example show? (never seem mapster, seems very interesting, have only used automapper mysef).