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