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.