Wednesday, September 12, 2018

Algolia - filters unexpected token string(organic)

When using the C# library to query an index in Algolia, the following error appeared after I attempted to filter the query on one of my facets:
filters: Unexpected token string(organic) expected end of filter at col 17
Algolia - unexpected token organic
How I was setting the filter was:
query.SetFilters("categories:a spaced value");
The error was because of the spaces in the filter/facet value I was trying to set. The correct way to call which resolved the error was:
query.SetFilters("categories:\"a spaced value\"");

Tuesday, September 11, 2018

Sitecore - A read lock may not be acquired with the write lock held in this mode

After making some changes to services I was registering for dependency injection (using the standard Sitecore implementation). I began getting the following error:
A read lock may not be acquired with the write lock held in this mode.
Sitecore dependency injection error
This was occurring as I was trying to access a Sitecore setting (configuration file) and this would error because you can't access this Sitecore resource whilst the container is being initialized. I was able to use a web.config app setting instead.

Saturday, September 8, 2018

Sitecore and Azure Search - Found 2 key fields in index

After changing an index definition I deleted my web index from Azure Search and re-created it ready to perform a full index rebuild. This led the following error:
Exception: Sitecore.ContentSearch.Azure.Http.Exceptions.AzureSearchServiceRESTCallException
Message: {"error":{"code":"","message":"The request is invalid. Details: index : Found 2 key fields in index 'sitecore-web-index-secondary'. Each index must have exactly one key field.\r\n"}}
This error occurred because when I created the index in Azure, I had left the default key field named id present.

Sitecore Azure Search - Create index
This was incorrect as Sitecore would try and add another key azureuniqueid. When creating the index, if you set that default key field to be called azureuniqueid, this error will not occur.

Friday, August 3, 2018

Sitecore Experience Commerce - index rebuild failure

When attempting to rebuild the web index for an experience commerce instance which contained a number of categories and sellable items, the following error occurred:
Exception: System.NullReferenceExceptionMessage: Object reference not set to an instance of an object.Source: Sitecore.Commerce.Engine.Connectat Sitecore.Commerce.Engine.Connect.Search.Crawlers.CatalogCrawlerBase`1.<>c__DisplayClass52_1.<AddItemsToIndex>b__0(CommerceCatalogIndexableItem indexable, ParallelLoopState loopState)
In the content editor by updating the data templates (commerce) and clearing the cache, the index would then rebuild to completion.

Friday, July 27, 2018

Sitecore Experience Commerce - SitecoreConnectionManager getitemsbypath failures

In the minions commerce engine role of my Experience Commerce 9 environment, I have an import minion which syncs product data into Sitecore. During it's run it ran into errors connecting to Sitecore (via API) to retrieve settings (via content items).
3 11:14:32 ERROR SitecoreConnectionManager: RETRY 1 out of 3 with ERROR Internal Server Error. Failed to logging. /sitecore/api/ssc/auth/login for GET /sitecore/api/ssc/item/?path=%2Fsitecore%2FCommerce%2FCommerce%20Control%20Panel%2FCommerce%20Engine%20Settings%2FCommerce%20Terms%2FBusinessTools%2FViewPropertyNames&database=master&language=en
4 11:14:32 ERROR SitecoreConnectionManager.Error: Message=RETRY FAILED for GET /sitecore/api/ssc/item/?path=%2Fsitecore%2FCommerce%2FCommerce%20Control%20Panel%2FCommerce%20Engine%20Settings%2FCommerce%20Terms%2FBusinessTools%2FViewPropertyNames&database=master&language=en|Trace=   at Sitecore.Commerce.Plugin.Management.SitecoreConnectionManager.<ProcessRequestAsync>d__15.MoveNext()
4 11:14:32 ERROR Management.block.getitemsbypath: Sitecore Item Service Get item failed, Item /sitecore/Commerce/Commerce Control Panel/Commerce Engine Settings/Commerce Terms/BusinessTools/ViewPropertyNames not found.
This error traced back to the PlugIn.Content.PolicySet-1.0.0.json policy set configuration file inside the commerce engine. In this file I had correctly configured the username and password for the Sitecore index, however the Host setting was still set to the default of As I don't use this domain, it had not been configured with a valid SSL certificate. By changing this host to the correct one (with a valid certificate) the errors no longer occurred.