Skip to content

Commit

Permalink
Merge pull request #34 from Kentico/feat/indexing-delay
Browse files Browse the repository at this point in the history
feat(indexing-delay): added support for optional customizable delay
  • Loading branch information
Rumec authored Nov 26, 2024
2 parents 5125796 + 87208b8 commit 36ec567
Show file tree
Hide file tree
Showing 49 changed files with 2,102 additions and 2,073 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ dotnet add package Kentico.Xperience.AzureSearch
"CMSAzureSearch": {
"SearchServiceEndPoint": "<your application url>",
"SearchServiceAdminApiKey": "<your application admin key>",
"SearchServiceQueryApiKey": "<your application query key>"
"SearchServiceQueryApiKey": "<your application query key>",

// Opotionally add delay between indexing items.
// This is useful if there are a lot of pages and items on your web which when crawled would increase the performance requirements.
"IndexItemDelay" : 0
}
```

Expand Down
Binary file modified database/DancingGoat_AzureAISearch.bak
Binary file not shown.
Binary file modified examples/DancingGoat/Data/Template.zip
Binary file not shown.
3 changes: 2 additions & 1 deletion examples/DancingGoat/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"SearchServiceEnabled": true,
"SearchServiceEndPoint": "",
"SearchServiceAdminApiKey": "",
"SearchServiceQueryApiKey": ""
"SearchServiceQueryApiKey": "",
"IndexItemDelay" : 0
}
}
110 changes: 55 additions & 55 deletions src/Kentico.Xperience.AzureSearch/Admin/AzureSearchAdminModule.cs
Original file line number Diff line number Diff line change
@@ -1,55 +1,55 @@
using CMS;
using CMS.Base;
using CMS.Core;

using Kentico.Xperience.Admin.Base;
using Kentico.Xperience.AzureSearch.Admin;
using Kentico.Xperience.AzureSearch.Aliasing;
using Kentico.Xperience.AzureSearch.Indexing;

using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;

[assembly: RegisterModule(typeof(AzureSearchAdminModule))]

namespace Kentico.Xperience.AzureSearch.Admin;

/// <summary>
/// Manages administration features and integration.
/// </summary>
internal class AzureSearchAdminModule : AdminModule
{
private IAzureSearchConfigurationStorageService storageService = null!;
private AzureSearchModuleInstaller installer = null!;

public AzureSearchAdminModule() : base(nameof(AzureSearchAdminModule)) { }

protected override void OnInit(ModuleInitParameters parameters)
{
base.OnInit(parameters);

var options = Service.Resolve<IOptions<AzureSearchOptions>>();

if (!options.Value?.SearchServiceEnabled ?? false)
{
return;
}

RegisterClientModule("kentico", "xperience-integrations-azuresearch");

var services = parameters.Services;

installer = services.GetRequiredService<AzureSearchModuleInstaller>();
storageService = services.GetRequiredService<IAzureSearchConfigurationStorageService>();

ApplicationEvents.Initialized.Execute += InitializeModule;
}

private void InitializeModule(object? sender, EventArgs e)
{
installer.Install();

AzureSearchIndexStore.SetIndicies(storageService);
AzureSearchIndexAliasStore.SetAliases(storageService);
}
}
using CMS;
using CMS.Base;
using CMS.Core;

using Kentico.Xperience.Admin.Base;
using Kentico.Xperience.AzureSearch.Admin;
using Kentico.Xperience.AzureSearch.Aliasing;
using Kentico.Xperience.AzureSearch.Indexing;

using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;

[assembly: RegisterModule(typeof(AzureSearchAdminModule))]

namespace Kentico.Xperience.AzureSearch.Admin;

/// <summary>
/// Manages administration features and integration.
/// </summary>
internal class AzureSearchAdminModule : AdminModule
{
private IAzureSearchConfigurationStorageService storageService = null!;
private AzureSearchModuleInstaller installer = null!;

public AzureSearchAdminModule() : base(nameof(AzureSearchAdminModule)) { }

protected override void OnInit(ModuleInitParameters parameters)
{
base.OnInit(parameters);

var options = Service.Resolve<IOptions<AzureSearchOptions>>();

if (!options.Value?.SearchServiceEnabled ?? false)
{
return;
}

RegisterClientModule("kentico", "xperience-integrations-azuresearch");

var services = parameters.Services;

installer = services.GetRequiredService<AzureSearchModuleInstaller>();
storageService = services.GetRequiredService<IAzureSearchConfigurationStorageService>();

ApplicationEvents.Initialized.Execute += InitializeModule;
}

private void InitializeModule(object? sender, EventArgs e)
{
installer.Install();

AzureSearchIndexStore.SetIndicies(storageService);
AzureSearchIndexAliasStore.SetAliases(storageService);
}
}
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
using System.Text.Json.Serialization;

namespace Kentico.Xperience.AzureSearch.Admin;

public class AzureSearchIndexIncludedPath
{
/// <summary>
/// The node alias pattern that will be used to match pages in the content tree for indexing.
/// </summary>
/// <remarks>For example, "/Blogs/Products/" will index all pages under the "Products" page.</remarks>
public string AliasPath { get; }

/// <summary>
/// A list of content types under the specified <see cref="AliasPath"/> that will be indexed.
/// </summary>
public List<AzureSearchIndexContentType> ContentTypes { get; set; } = [];

/// <summary>
/// The internal identifier of the included path.
/// </summary>
public string? Identifier { get; set; }

[JsonConstructor]
public AzureSearchIndexIncludedPath(string aliasPath) => AliasPath = aliasPath;

/// <summary>
///
/// </summary>
/// <param name="indexPath"></param>
/// <param name="contentTypes"></param>
public AzureSearchIndexIncludedPath(AzureSearchIncludedPathItemInfo indexPath, IEnumerable<AzureSearchIndexContentType> contentTypes)
{
AliasPath = indexPath.AzureSearchIncludedPathItemAliasPath;
ContentTypes = contentTypes.ToList();
Identifier = indexPath.AzureSearchIncludedPathItemId.ToString();
}
}
using System.Text.Json.Serialization;

namespace Kentico.Xperience.AzureSearch.Admin;

public class AzureSearchIndexIncludedPath
{
/// <summary>
/// The node alias pattern that will be used to match pages in the content tree for indexing.
/// </summary>
/// <remarks>For example, "/Blogs/Products/" will index all pages under the "Products" page.</remarks>
public string AliasPath { get; }

/// <summary>
/// A list of content types under the specified <see cref="AliasPath"/> that will be indexed.
/// </summary>
public List<AzureSearchIndexContentType> ContentTypes { get; set; } = [];

/// <summary>
/// The internal identifier of the included path.
/// </summary>
public string? Identifier { get; set; }

[JsonConstructor]
public AzureSearchIndexIncludedPath(string aliasPath) => AliasPath = aliasPath;

/// <summary>
///
/// </summary>
/// <param name="indexPath"></param>
/// <param name="contentTypes"></param>
public AzureSearchIndexIncludedPath(AzureSearchIncludedPathItemInfo indexPath, IEnumerable<AzureSearchIndexContentType> contentTypes)
{
AliasPath = indexPath.AzureSearchIncludedPathItemAliasPath;
ContentTypes = contentTypes.ToList();
Identifier = indexPath.AzureSearchIncludedPathItemId.ToString();
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Kentico.Xperience.AzureSearch.Admin;

internal static class AzureSearchIndexPermissions
{
public const string REBUILD = "Rebuild";
}
namespace Kentico.Xperience.AzureSearch.Admin;

internal static class AzureSearchIndexPermissions
{
public const string REBUILD = "Rebuild";
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
namespace Kentico.Xperience.AzureSearch.Admin;

public class AzureSearchIndexStatisticsViewModel
{
//
// Summary:
// Index name.
public string? Name { get; set; }

//
// Summary:
// Number of records contained in the index
public long Entries { get; set; }
}
namespace Kentico.Xperience.AzureSearch.Admin;

public class AzureSearchIndexStatisticsViewModel
{
//
// Summary:
// Index name.
public string? Name { get; set; }

//
// Summary:
// Number of records contained in the index
public long Entries { get; set; }
}
Loading

0 comments on commit 36ec567

Please sign in to comment.