Rebuild examine index fail, cannot deserialize the current JSON array
r

Rasolo

about 1 year ago
I get an error when trying to rebuild the examine index (umbraco 12) this is a new issue from upgrading from 8 to 12. Any advice in solving? Error message: Newtonsoft.Json.JsonSerializationException: Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'Umbraco.Cms.Core.Models.Blocks.BlockValue' because the type requires a JSON object (e.g. {"name":"value"}) to deserialize correctly. To fix this error either change the JSON to a JSON object (e.g. {"name":"value"}) or change the deserialized type to an array or a type that implements a collection interface (e.g. ICollection, IList) like List that can be deserialized from a JSON array. JsonArrayAttribute can also be added to the type to force it to deserialize from a JSON array. Path '', line 1, position 1. at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureArrayContract(JsonReader reader, Type objectType, JsonContract contract) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue) at Newto at System.Collections.Generic.LargeArrayBuilder`1.AddRange(IEnumerable`1 items) at System.Collections.Generic.EnumerableHelpers.ToArray[T](IEnumerable`1 source) at Umbraco.Cms.Infrastructure.Examine.ContentIndexPopulator.IndexAllContent(Int32 contentParentId, Int32 pageIndex, Int32 pageSize, IReadOnlyList`1 indexes) at Umbraco.Cms.Infrastructure.Examine.ContentIndexPopulator.PopulateIndexes(IReadOnlyList`1 indexes) at Umbraco.Cms.Infrastructure.Examine.IndexPopulator.Populate(IIndex[] indexes) ...
[Solved] Help with Examine RangeQuery for Custom Date Field in Umbraco
u

2lach

about 1 year ago
Hello, I'm working on an Umbraco application for a client (version 13) and am encountering issues while using Examine to perform a RangeQuery on a custom date field. My field, named
searchableDateField
, doesn't seem to be indexed in the same manner as Umbracoโ€™s built-in createDate field, despite my efforts to convert
searchableDateField
to the DateTime format ticks, which I believe is also used for
createDate
. When I execute the following query:
query.And(q => q.RangeQuery(new[] { "searchableDateField" }, startDate, endDate, minInclusive: true, maxInclusive: false));
I receive this error message from Examine:
"An error occurred during the search: Could not perform a range query on the field searchableDateField, its value type is Examine.Lucene.Indexing.FullTextType"
Interestingly, when I replace
searchableDateField
with
createDate
, the query works fine and returns the expected results (the documents with a `createDate`between
DateTime startDate
and
DateTime endDate
query.And(q => q.RangeQuery(new[] { "createDate" }, startDate, endDate, minInclusive: true, maxInclusive: false));
I currently save the value of
searchableDateField
in a label in Umbraco as a DateTime (DateTime format Ticks). I have also tried saving the
searchableDateField
in various DateTime formats (both in dateTime labels and fields) and in the compatible types of labels, such as string, BigInt, etc. i could think of and then casting them as DateTime values. However, my results remains the same as described above. The main difference I can think of is that
createDate
exists on all my DocumentTypes, whereas
searchableDateField
does not always exist on all DocumentTypes. If anyone has experience working with custom date fields in Examine and Umbraco and can offer guidance or suggest a solution (even a creative one, as I really want to solve this), I would be very grateful for any tips or advice. Thanks