Skip to content

Instantly share code, notes, and snippets.

View jstemerdink's full-sized avatar

Jeroen jstemerdink

View GitHub Profile
using Alloy12.Models.Media;
using EPiServer.DataAbstraction.Migration;
using System.Data.Common;
using System.Data;
using System.Globalization;
using EPiServer.Data;
using Newtonsoft.Json;
using EPiServer.ServiceLocation;
namespace Alloy12.Business.Migrations
@jstemerdink
jstemerdink / SearchExtensions.cs
Created January 27, 2025 08:17
Make Best Bets and synonyms work with wildcard queries in Optimizely Search and Navigation
public static IQueriedSearch<TSource, QueryStringQuery> UsingSynonyms<TSource>(
this IQueriedSearch<TSource> search, string queryString)
{
search.ValidateNotNullArgument(nameof (search));
if (search.Client.Settings.Admin)
{
return new Search<TSource, QueryStringQuery>(search, context =>
{
if (!(context.RequestBody.Query is QueryStringQuery query2))
/// <summary>
/// Class FacetAttribute. This class cannot be inherited.
/// </summary>
[AttributeUsage(AttributeTargets.Property)]
public sealed class FacetAttribute : Attribute
{
/// <summary>
/// Initializes a new instance of the <see cref="FacetAttribute"/> class.
/// </summary>
/// <param name="index">The index.</param>
public class CustomCatalogItemChangeManager : CatalogItemChangeManager
{
private readonly IScheduledJobRepository scheduledJobRepository;
public CustomCatalogItemChangeManager(
IChangeNotificationManager changeNotificationManager,
EntryIdentityResolver entryIdentityResolver,
IScheduledJobRepository scheduledJobRepository)
: base(changeNotificationManager: changeNotificationManager, entryIdentityResolver: entryIdentityResolver)
{
public void GetProductUrl(ProductContent product, ContentReference catalogLink, out string path)
{
path = product.RouteSegment;
ContentReference parentLink = product.ParentLink;
if (catalogLink.CompareToIgnoreWorkID(contentReference: parentLink))
{
return;
}
{
"Serilog": {
"Using": [ "Serilog.Sinks.File" ],
"MinimumLevel": {
"Default": "Information",
"Override": {
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information",
"EPiserver": "Information",
"EPiServer.Commerce": "Debug"
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Linq.Expressions;
using EPiServer;
using EPiServer.Commerce.Catalog.ContentTypes;
using EPiServer.Core;
using EPiServer.Find;
CREATE TABLE [dbo].[tblFindTrackingQueue]
(
[Id] [bigint] IDENTITY(1,1) NOT NULL,
[TrackingId] [nvarchar](max) NOT NULL,
[NrOfHits] [int] NOT NULL,
[Query] [nvarchar](max) NOT NULL,
[Tags] [nvarchar](max) NOT NULL
);
GO
@jstemerdink
jstemerdink / autocorrect.cs
Created November 12, 2019 14:30
Auto correct the query before sending it to your search engine
public string AutoCorrect(string query)
{
if (query.Length < 5)
{
return query;
}
SpellCheckClient spellCheckClient = new SpellCheckClient(new ApiKeyServiceClientCredentials("Your_BING_SpellCheck_Key_Here"));
HttpOperationResponse<SpellCheckModel> result = spellCheckClient.SpellCheckerWithHttpMessagesAsync(text: query, mode: "spell", setLang: ContentLanguage.PreferredCulture.TwoLetterISOLanguageName).Result;
public class Global : EPiServer.Global
{
protected void Application_Start()
{
// Other stuff here
// See: https://support.microsoft.com/en-gb/help/821268/contention-poor-performance-and-deadlocks-when-you-make-calls-to-web-s
// See: https://docs.microsoft.com/en-us/azure/redis-cache/cache-faq
SetMinThreads();
SetMaxThreads();