Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Azure AI Search (Azure Cognitive Search) #14925

Merged
merged 35 commits into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
dfc976f
adding project
MikeAlhayek Dec 18, 2023
0e199fb
Add Azure Cognative Search services
MikeAlhayek Dec 19, 2023
7386793
Add indices UI
MikeAlhayek Dec 20, 2023
2c6c174
Finish the search
MikeAlhayek Dec 20, 2023
500a13b
cleanup
MikeAlhayek Dec 20, 2023
f255a68
cleanup
MikeAlhayek Dec 20, 2023
e1f3725
cleanup
MikeAlhayek Dec 21, 2023
4b8e039
cleanup
MikeAlhayek Dec 21, 2023
796ad02
Update README.md
MikeAlhayek Dec 21, 2023
d18850a
Merge remote-tracking branch 'origin/main' into ma/cognative-search
MikeAlhayek Dec 21, 2023
5b75283
Move all the search settings into a single menu item.
MikeAlhayek Dec 21, 2023
2dca75c
Change how indexes are created by maintaing map
MikeAlhayek Dec 22, 2023
470fab8
Rebrand Azure Cognative Search to Azure AI Search
MikeAlhayek Dec 22, 2023
70faa1b
Merge branch 'main' into ma/cognative-search
MikeAlhayek Dec 22, 2023
d7007fe
file renaming for consistency
MikeAlhayek Dec 22, 2023
445356d
cleanup
MikeAlhayek Dec 22, 2023
cf08cd5
Fix build
MikeAlhayek Dec 22, 2023
e5c5633
menu cleanup
MikeAlhayek Dec 22, 2023
0d63da6
Add AzureAISearchIndexingService to allow populating items
MikeAlhayek Dec 23, 2023
366e61e
Added way to reset and rebuid index
MikeAlhayek Dec 23, 2023
b0fd28d
Adding recipe, deployment steps, and update docs.
MikeAlhayek Dec 23, 2023
2219cd0
add 1.9.0 release notes
MikeAlhayek Dec 23, 2023
81783e7
update code owners
MikeAlhayek Dec 26, 2023
17a3251
cleanup
MikeAlhayek Dec 26, 2023
90fd24f
Add events, add naming tests, cleanup helpers
MikeAlhayek Dec 28, 2023
3e4d84d
Add document events
MikeAlhayek Dec 28, 2023
1f7ac85
fix the pager
MikeAlhayek Dec 28, 2023
53b0541
simplify
MikeAlhayek Dec 28, 2023
c296e3f
cleanup
MikeAlhayek Dec 28, 2023
d5ec931
cleanup
MikeAlhayek Dec 31, 2023
f491e87
cleanup
MikeAlhayek Dec 31, 2023
e49f5eb
Store full name of the index in settings
MikeAlhayek Jan 2, 2024
b9d8f7f
Merge remote-tracking branch 'origin/main' into ma/cognative-search
MikeAlhayek Jan 2, 2024
f54f437
update docs
MikeAlhayek Jan 2, 2024
db8e5d8
Finalize docs
MikeAlhayek Jan 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion OrchardCore.sln
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OrchardCore.Sms.Abstraction
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OrchardCore.Sms", "src\OrchardCore.Modules\OrchardCore.Sms\OrchardCore.Sms.csproj", "{CBF6DB53-FD0C-47F8-9E60-A1D247ACFD05}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OrchardCore.Sms.Core", "src\OrchardCore\OrchardCore.Sms.Core\OrchardCore.Sms.Core.csproj", "{20356393-B16D-466C-8203-877A534E287D}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OrchardCore.Sms.Core", "src\OrchardCore\OrchardCore.Sms.Core\OrchardCore.Sms.Core.csproj", "{20356393-B16D-466C-8203-877A534E287D}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OrchardCore.Search.AzureAI", "src\OrchardCore.Modules\OrchardCore.Search.AzureAI\OrchardCore.Search.AzureAI.csproj", "{5527BACF-FA5D-4617-978B-7EDE8942E6F6}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OrchardCore.Search.AzureAI.Core", "src\OrchardCore\OrchardCore.Search.AzureAI.Core\OrchardCore.Search.AzureAI.Core.csproj", "{E9428DE8-5D81-4359-BF84-31435041FF1A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -1335,6 +1339,14 @@ Global
{20356393-B16D-466C-8203-877A534E287D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{20356393-B16D-466C-8203-877A534E287D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{20356393-B16D-466C-8203-877A534E287D}.Release|Any CPU.Build.0 = Release|Any CPU
{5527BACF-FA5D-4617-978B-7EDE8942E6F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5527BACF-FA5D-4617-978B-7EDE8942E6F6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5527BACF-FA5D-4617-978B-7EDE8942E6F6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5527BACF-FA5D-4617-978B-7EDE8942E6F6}.Release|Any CPU.Build.0 = Release|Any CPU
{E9428DE8-5D81-4359-BF84-31435041FF1A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E9428DE8-5D81-4359-BF84-31435041FF1A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E9428DE8-5D81-4359-BF84-31435041FF1A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E9428DE8-5D81-4359-BF84-31435041FF1A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -1566,6 +1578,8 @@ Global
{2D93F509-1FB3-4E22-92F0-588D0EFBA921} = {F23AC6C2-DE44-4699-999D-3C478EF3D691}
{CBF6DB53-FD0C-47F8-9E60-A1D247ACFD05} = {A066395F-6F73-45DC-B5A6-B4E306110DCE}
{20356393-B16D-466C-8203-877A534E287D} = {F23AC6C2-DE44-4699-999D-3C478EF3D691}
{5527BACF-FA5D-4617-978B-7EDE8942E6F6} = {90030E85-0C4F-456F-B879-443E8A3F220D}
{E9428DE8-5D81-4359-BF84-31435041FF1A} = {F23AC6C2-DE44-4699-999D-3C478EF3D691}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {46A1D25A-78D1-4476-9CBF-25B75E296341}
Expand Down
2 changes: 2 additions & 0 deletions src/OrchardCore.Build/Dependencies.props
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<PackageManagement Include="Azure.Extensions.AspNetCore.Configuration.Secrets" Version="1.3.0" />
<PackageManagement Include="Azure.Extensions.AspNetCore.DataProtection.Blobs" Version="1.3.2" />
<PackageManagement Include="Azure.Identity" Version="1.10.4" />
<PackageManagement Include="Azure.Search.Documents" Version="11.5.1" />
<PackageManagement Include="Azure.Storage.Blobs" Version="12.19.1" />
<PackageManagement Include="BenchmarkDotNet" Version="0.13.11" />
<PackageManagement Include="Castle.Core" Version="5.1.1" />
Expand All @@ -36,6 +37,7 @@
<PackageManagement Include="MailKit" Version="4.3.0" />
<PackageManagement Include="Markdig" Version="0.34.0" />
<PackageManagement Include="MessagePack" Version="2.2.60" />
<PackageManagement Include="Microsoft.Extensions.Azure" Version="1.7.1" />
<PackageManagement Include="Microsoft.Identity.Web" Version="2.16.0" />
<PackageManagement Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageManagement Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
Expand Down
18 changes: 17 additions & 1 deletion src/OrchardCore.Cms.Web/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,22 @@
// "MaxPagedCount": 500
// }
//},
// Provides Azure AI Search Connection
//"OrchardCore_AzureAISearch": {
// "Endpoint": "",
// "IndexesPrefix": "",
// "Credential": {
// "Key": ""
// }
//},
// "Url": "http://localhost",
// "Ports": [ 9200 ],
// "Username": "admin",
// "Password": "admin",
// "CloudId": "Orchard_Core_deployment:ZWFzdHVzMi5henVyZS5lbGFzdGljLWNsb3VkLmNvbTo0NDMkNmMxZGQ4YzAzN2=",
// "CertificateFingerprint": "75:21:E7:92:8F:D5:7A:27:06:38:8E:A4:35:FE:F5:17:D7:37:F4:DF:F0:9A:D2:C0:C4:B6:FF:EE:D1:EA:2B:A7",
// "EnableApiVersioningHeader": false
//},
// Provides Elasticsearch Connection
//"OrchardCore_Elasticsearch": {
// "ConnectionType": "SingleNodeConnectionPool",
Expand All @@ -143,7 +159,7 @@
// "CloudId": "Orchard_Core_deployment:ZWFzdHVzMi5henVyZS5lbGFzdGljLWNsb3VkLmNvbTo0NDMkNmMxZGQ4YzAzN2=",
// "CertificateFingerprint": "75:21:E7:92:8F:D5:7A:27:06:38:8E:A4:35:FE:F5:17:D7:37:F4:DF:F0:9A:D2:C0:C4:B6:FF:EE:D1:EA:2B:A7",
// "EnableApiVersioningHeader": false
//}
//},
// WARNING: AutoSetup section given as an example for Development only, for Production use "Environment Variables" instead
//"OrchardCore_AutoSetup": {
// "AutoSetupPath": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,18 @@ public override Task BuildIndexAsync(NumericField field, BuildFieldIndexContext
var settings = context.ContentPartFieldDefinition.GetSettings<NumericFieldSettings>();
var options = context.Settings.ToOptions();

if (settings.Scale == 0)
var isInteger = settings.Scale == 0;

foreach (var key in context.Keys)
{
foreach (var key in context.Keys)
if (isInteger)
{
context.DocumentIndex.Set(key, (int?)field.Value, options);

continue;
}
}
else
{
foreach (var key in context.Keys)
{
context.DocumentIndex.Set(key, field.Value, options);
}

context.DocumentIndex.Set(key, field.Value, options);
}

return Task.CompletedTask;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public async override Task BuildIndexAsync(MediaField field, BuildFieldIndexCont
var options = context.Settings.ToOptions();
var settings = context.ContentPartFieldDefinition.GetSettings<MediaFieldSettings>();

if (field.Paths?.Length == 0)
if (field.Paths?.Length is null || field.Paths.Length == 0)
{
foreach (var key in context.Keys)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using Microsoft.Extensions.Localization;
using Microsoft.Extensions.Options;
using OrchardCore.DisplayManagement;
using OrchardCore.DisplayManagement.Extensions;
using OrchardCore.DisplayManagement.ModelBinding;
using OrchardCore.DisplayManagement.Notify;
using OrchardCore.Entities;
Expand Down Expand Up @@ -106,19 +107,11 @@ public async Task<IActionResult> List(
new(S["Remove"], nameof(NotificationBulkAction.Remove)),
];

var routeData = new RouteData(options.RouteValues);
var pager = new Pager(pagerParameters, _pagerOptions.GetPageSize());

var queryResult = await _notificationsAdminListQueryService.QueryAsync(pager.Page, pager.PageSize, options, this);

dynamic pagerShape = await _shapeFactory.CreateAsync("Pager", Arguments.From(new
{
pager.Page,
pager.PageSize,
TotalItemCount = queryResult.TotalCount
}));

pagerShape.RouteData(routeData);
dynamic pagerShape = await _shapeFactory.PagerAsync(pager, queryResult.TotalCount, options.RouteValues);

var notificationSummaries = new List<dynamic>();

Expand Down
34 changes: 34 additions & 0 deletions src/OrchardCore.Modules/OrchardCore.Search.AzureAI/AdminMenu.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using System;
using System.Threading.Tasks;
using Microsoft.Extensions.Localization;
using OrchardCore.Navigation;

namespace OrchardCore.Search.AzureAI;

public class AdminMenu(IStringLocalizer<AdminMenu> stringLocalizer) : INavigationProvider
{
protected readonly IStringLocalizer S = stringLocalizer;

public Task BuildNavigationAsync(string name, NavigationBuilder builder)
{
if (!string.Equals(name, "admin", StringComparison.OrdinalIgnoreCase))
{
return Task.CompletedTask;
}

builder
.Add(S["Search"], NavigationConstants.AdminMenuSearchPosition, search => search
.AddClass("azure-ai-service")
.Id("azureaiservice")
.Add(S["Indexing"], S["Indexing"].PrefixPosition(), indexing => indexing
.Add(S["Azure AI Indices"], S["Azure AI Indices"].PrefixPosition(), indexes => indexes
.Action("Index", "Admin", new { area = "OrchardCore.Search.AzureAI" })
.Permission(AzureAISearchIndexPermissionHelper.ManageAzureAISearchIndexes)
.LocalNav()
)
)
);

return Task.CompletedTask;
}
}
Loading