Two issues with Sitrecore XMCloud Edge and how to resolve this with Sitecore support.
The old data in Edge.
Some time ago, when I was working with content, I encountered an issue where the published content was not updating in Edge. I tried republishing everything and also cleared the cache through the Admin API, but nothing seemed to help.
What is happening with content? When I started working on a new project, I initially had a test home page with content. After some development time, our team changed the home item (template and item ID), and that was when I faced this issue.
I created a Sitecore support ticket because I had no idea what was happening or how to resolve it. After discussing the issue with Sitecore support, they advised me to delete all tenant data. When I deleted all the data and republished everything, it started to work again. To delete the content, I used the Admin API (https://doc.sitecore.com/xmc/en/developers/xm-cloud/admin-api.html#deletecontent).
Search items by updated date.
For my purposes, I need to retrieve pages that were updated in the last day from Edge. I attempted to filter by the __Updated field (a field from statistics), but of course it is not working and I get issue: The field 'Updated' is not supported. The list of available predefined fields: '_name', '_path', '_parent', '_templates', '_hasLayout' and '_language'.
Here is an example of the query I used:
query {
search(
where: { AND: [{ name: "__Updated", value: "20240611", operator: CONTAINS }] }
) {
results {
id
name
updated: field(name: "__Updated") {
value
}
}
}
}
Additionally, I found that _hasLayout is a computed field. I attempted to add a custom computed field. To do this, I created the computed field code and added it to the defaultSolrIndexConfiguration. Below you can see an example:
领英推荐
<contentSearch patch:source="Sitecore.ContentSearch.ContentExtraction.config">
<indexConfigurations>
<defaultSolrIndexConfiguration type="Sitecore.ContentSearch.SolrProvider.SolrIndexConfiguration, Sitecore.ContentSearch.SolrProvider" patch:source="Sitecore.XA.Foundation.Search.Solr.XMCloud.config">
<documentOptions type="Sitecore.ContentSearch.SolrProvider.SolrDocumentBuilderOptions, Sitecore.ContentSearch.SolrProvider" patch:source="Sitecore.XA.Foundation.Search.Solr.XMCloud.config">
<fields hint="raw:AddComputedIndexField" patch:source="Sitecore.XA.Foundation.Search.Solr.XMCloud.config">
<field type="Alia.Foundation.SitecoreExtensions.EdgeSchema.ComputedFields.UpdatedComputedField, MyProject.Foundation.SitecoreExtensions" fieldName="statUpdated" returnType="string" />
</fields>
</documentOptions>
</defaultSolrIndexConfiguration>
</indexConfigurations>
</contentSearch>
public class UpdatedComputedField : IComputedIndexField
{
public string FieldName { get; set; }
public string ReturnType { get; set; }
public object ComputeFieldValue(IIndexable indexable)
{
Item item = indexable as SitecoreIndexableItem;
if (item == null)
{
return null;
}
return item.Statistics.Updated.ToString("yyyyMMdd");
}
}
Unfortunately, this computed field also didn't work and Edge didn't recognize it. After this, I created another Sitecore support ticket, hoping that the support team could help me. Sitecore support responded with the following advice:
Please consider using the updateddaterange field. The valid values for the updateddaterange field are:
These values should be automatically converted to actual dates during query execution. If you want to use the __Updated or smallupdateddate fields, the operators should be LT, LTE, GT, GTE. The CONTAINS operator would look for an exact match.
I was pleasantly surprised to find that Edge has features such as updateddaterange and filters like LT, LTE, GT, GTE. I immediately checked this functionality. Upon testing, I obtained the following results: updateddaterange works in the local environment. For instance, when I created a search query with the filter updateddaterange == thismonth, I received results.
query {
search(
where: { AND: [{ name: "updateddaterange", value: "lastmonth", operator: EQ }] }
) {
results {
id
name
updated: field(name: "__Updated") {
value
}
}
}
}
But for live Edge, it isn't working. I was initially pleased to discover that Edge included features such as filters like LT, LTE, GT, GTE. However, upon testing the same query in the live Edge environment, it did not function as expected. This issue persisted both locally and in the live Edge environment.
After conducting experiments, I reached out to Sitecore support to report my findings. Shortly thereafter, Sitecore support responded, informing me that they have created a feature request regarding updateddaterange and __Updated, which will be included in future releases. Regarding LT, LTE, GT, GTE filters, Sitecore support mentioned that they can enable these filters for my project, but they will only be available for the Delivery API and cannot be used with the same syntax in the Edge Preview API, because it is experemental feature.
In conclusion, I would like to express my gratitude to Sitecore support for their assistance with my issues. Additionally, I have learned that Edge has the potential to become more robust in the future. I am hopeful that Sitecore will incorporate support for fields like Created, Updated, and Published, along with adding LT, LTE, GT, and GTE filters. This enhancement would undoubtedly facilitate developers in creating more advanced search features.