[BUG] Search: Support model serialization
See original GitHub issueLibrary name and version
using Azure.Search.Documents 11.0.0
Describe the bug
Calling SearchAsSync Giving a object of SearchResult<T> on serializing this document. In Facets only value is getting serialized other properties (count , to , from ) are getting added to the actual string
Sample Code :
SearchOptions searchOption = new SearchOptions();
searchOption.IncludeTotalCount = true;
searchOption.QueryType = SearchQueryType.Full;
searchOption.Facets.Add("someField");
SearchResults<T> results = await searchClient.SearchAsync<T>("*", searchOptions)
string result = JsonSerializer.Serialize(results);
Console.WriteLine(result);
Expected behavior
should add all values of facets (count, to , from) on seralization of searchResult.
Actual behavior
If you see in facet object just value is coming (count, from , to) are not coming.
{“TotalCount”:20,“Coverage”:null,“Facets”:{“someValue”:[{“value”:“111”},{“value”:“1111”},{“value”:“11111”},{“value”:“1119”},{“value”:“1219”},{“value”:“123456”},{“value”:“126”},{“value”:“1260”},{“value”:“1267”},{“value”:“1268”}]}}
Reproduction Steps
Given a sample code.
Environment
.Net versio 6 Visual Studio 2022
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Did destroy serialized data - [Better Search Replace] Review
The issue starts with method BSR_DB::recursive_unserialize_replace() , which recursively deserializes data. The cause is an assignment error. You can find this ...
Read more >How to handle a Findbugs "Non-transient non-serializable ...
Consider the class below. If I run Findbugs against it it will give me an error ("Non-transient non-serializable instance field in serializable ......
Read more >Object Serialization Enhancements
Deserialization behavior differs as well--the class information is used to find the appropriate enum class, and the Enum.valueOf method is called with that ......
Read more >SerializationException: There was an error deserializing ...
I have just started making an app (following someone) using a movie API from tmdb. There appears to be an issue with the...
Read more >serialization error [problem with setting attr values in the ...
I have double checked all of the mappings. I have double checked if the WSDL of the web service. hasn't been modified after...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @manijndl7. Thank you for your feedback.
Currently we intentionally do not support serialization/deserialization for Azure SDK model types due to the challenges associated with guaranteeing serialization compatibility across versions. While our public APIs have strong compatibility guarantees, serialization compatibility brings a different set of challenges. As a result, this is a feature that needs careful design and approval by our API governance board. We’ve had similar feedback in the past, so we’re aware this is a feature that there is interested in. I’ve tagged this as a feature request and moved this to the backlog for consideration.
As a work-around for serialization in the meantime, you may want to consider calling
results.GetRawResponse().Content
. This gives you a BinaryData instance that represents the service response, allowing you to retrieve the JSON content as a string or write it out to aUtf8JsonWriter
or similar.There is a new feature that will soon be released to enable this capability: https://github.com/Azure/azure-sdk-for-net/issues/16977. Mark this problem as duplicate and close.