1

How do you apply a DateTime field comparison in Sitecore using the Sitecore.ContentSearch SDK?

The ContentSearchResult[string key] function always returns a string which cannot be cast into a DateTime for comparisons.

1 Answer 1

1

The solution to this is to use the following function overload:

ContentSearchResult[ObjectIndexerKey key].

Example Query:

queryable = queryable.Where(p =>
   ((DateTime)p[(ObjectIndexerKey)"Date"]) > lastWeek.Boost(4f)
);

Note: The boost above does not appear to be translated in the query

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.