[QUERY] Search: SearchClient.Search Value cannot be null. (Parameter 's')
See original GitHub issueQuery/Question
SearchClient.Search sometimes randomly fails with a very unclear error message. Could you give some guidance what could be the problem and how it could be resolved? Retrying the same query, does not replicate the issue 😦
Error:
System.ArgumentNullException: Value cannot be null. (Parameter 's') at Azure.Search.Documents.SearchDateTimeConverter.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options) at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value) at System.Text.Json.JsonPropertyInfo`1.ReadJsonAndSetMember(Object obj, ReadStack& state, Utf8JsonReader& reader) at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value) at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value) at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state) at System.Text.Json.JsonSerializer.ReadCore[TValue](JsonReaderState& readerState, Boolean isFinalBlock, ReadOnlySpan`1 buffer, JsonSerializerOptions options, ReadStack& state, JsonConverter converterBase) at System.Text.Json.JsonSerializer.ReadAsync[TValue](Stream utf8Json, Type returnType, JsonSerializerOptions options, CancellationToken cancellationToken) at Azure.Search.Documents.Models.SearchResult`1.DeserializeAsync(JsonElement element, ObjectSerializer serializer, JsonSerializerOptions options, Boolean async, CancellationToken cancellationToken) at Azure.Search.Documents.Models.SearchResults`1.DeserializeAsync(Stream json, ObjectSerializer serializer, Boolean async, CancellationToken cancellationToken) at Azure.Search.Documents.SearchClient.SearchInternal[T](SearchOptions options, String operationName, Boolean async, CancellationToken cancellationToken)
Environment:
- Azure.Search.Documents v11
- .NET SDK 5.0.200-preview.20614.14
- IDE and version : Visual Studio Version 16.9.0 Preview 3.0
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (6 by maintainers)
Top GitHub Comments
Thanks for the update @Valdeminas. And thanks @lucasroccoCM for sharing your solution. It will help future users who find this discussion.
Hi guys! How are you? I received the same problem described above, and I solved this turning my .NET Class property into Datetime? “Nullable” because, some indexes has null date value. { “@search.score”: 6.1858664, “id”: “5326”, “title”: “CALENDÁRIO ACADÊMICO 2021.1 EAD (5).pdf”, “content”: “Calendário Acadêmico 21.1 EAD atualizado em 10/06”, “date”: null, “url”: null },
///
/// Data do item indexado
///
[JsonPropertyName(“date”)]
[SearchableField(IsFilterable = true, IsSortable = true)]
public DateTime? Date { get; set; }
I hope this helped someone. My best regards, Lucas Rocco