Skip to content

Commit

Permalink
ElasticSearch first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Skrypt committed Mar 30, 2022
1 parent 0d1511c commit 55819e6
Show file tree
Hide file tree
Showing 125 changed files with 4,626 additions and 89 deletions.
21 changes: 21 additions & 0 deletions OrchardCore.sln
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OrchardCore.Roles.Core", "s
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OrchardCore.AutoSetup", "src\OrchardCore.Modules\OrchardCore.AutoSetup\OrchardCore.AutoSetup.csproj", "{1E76C17C-099A-4E6D-BC26-E93CBA4D0BD6}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OrchardCore.Search.Elastic.Abstractions", "src\OrchardCore\OrchardCore.Search.Elastic.Abstractions\OrchardCore.Search.Elastic.Abstractions.csproj", "{E6A90BFD-AB5C-4AED-A5AB-799136AB1521}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OrchardCore.Search.Elastic.Core", "src\OrchardCore\OrchardCore.Search.Elastic.Core\OrchardCore.Search.Elastic.Core.csproj", "{848C919B-6829-4758-9E59-51F13D25ABBC}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OrchardCore.Search.Elastic", "src\OrchardCore.Modules\OrchardCore.Search.Elastic\OrchardCore.Search.Elastic.csproj", "{B6A54EA8-F285-436D-8257-6F6EDE4C3339}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OrchardCore.Data.YesSql", "src\OrchardCore\OrchardCore.Data.YesSql\OrchardCore.Data.YesSql.csproj", "{F06E4E20-3675-4BA5-AD2D-4538FAB154D5}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OrchardCore.Data.YesSql.Abstractions", "src\OrchardCore\OrchardCore.Data.YesSql.Abstractions\OrchardCore.Data.YesSql.Abstractions.csproj", "{AB47A65C-7BA9-4CE7-BA73-285EB7A2CEFD}"
Expand Down Expand Up @@ -1100,6 +1106,18 @@ Global
{1E76C17C-099A-4E6D-BC26-E93CBA4D0BD6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1E76C17C-099A-4E6D-BC26-E93CBA4D0BD6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1E76C17C-099A-4E6D-BC26-E93CBA4D0BD6}.Release|Any CPU.Build.0 = Release|Any CPU
{E6A90BFD-AB5C-4AED-A5AB-799136AB1521}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E6A90BFD-AB5C-4AED-A5AB-799136AB1521}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E6A90BFD-AB5C-4AED-A5AB-799136AB1521}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E6A90BFD-AB5C-4AED-A5AB-799136AB1521}.Release|Any CPU.Build.0 = Release|Any CPU
{848C919B-6829-4758-9E59-51F13D25ABBC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{848C919B-6829-4758-9E59-51F13D25ABBC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{848C919B-6829-4758-9E59-51F13D25ABBC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{848C919B-6829-4758-9E59-51F13D25ABBC}.Release|Any CPU.Build.0 = Release|Any CPU
{B6A54EA8-F285-436D-8257-6F6EDE4C3339}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B6A54EA8-F285-436D-8257-6F6EDE4C3339}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B6A54EA8-F285-436D-8257-6F6EDE4C3339}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B6A54EA8-F285-436D-8257-6F6EDE4C3339}.Release|Any CPU.Build.0 = Release|Any CPU
{F06E4E20-3675-4BA5-AD2D-4538FAB154D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F06E4E20-3675-4BA5-AD2D-4538FAB154D5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F06E4E20-3675-4BA5-AD2D-4538FAB154D5}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -1310,6 +1328,9 @@ Global
{1D0144D0-9E6D-441B-A393-B62F6DC8E97E} = {90030E85-0C4F-456F-B879-443E8A3F220D}
{15E0499A-815D-4E98-B1E4-1C9D7B3D1461} = {F23AC6C2-DE44-4699-999D-3C478EF3D691}
{1E76C17C-099A-4E6D-BC26-E93CBA4D0BD6} = {A066395F-6F73-45DC-B5A6-B4E306110DCE}
{E6A90BFD-AB5C-4AED-A5AB-799136AB1521} = {F23AC6C2-DE44-4699-999D-3C478EF3D691}
{848C919B-6829-4758-9E59-51F13D25ABBC} = {F23AC6C2-DE44-4699-999D-3C478EF3D691}
{B6A54EA8-F285-436D-8257-6F6EDE4C3339} = {90030E85-0C4F-456F-B879-443E8A3F220D}
{F06E4E20-3675-4BA5-AD2D-4538FAB154D5} = {F23AC6C2-DE44-4699-999D-3C478EF3D691}
{AB47A65C-7BA9-4CE7-BA73-285EB7A2CEFD} = {F23AC6C2-DE44-4699-999D-3C478EF3D691}
{442C544F-6587-4FA5-8459-710ED8492AD4} = {F23AC6C2-DE44-4699-999D-3C478EF3D691}
Expand Down
2 changes: 1 addition & 1 deletion src/OrchardCore.Build/Dependencies.props
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<PackageManagement Include="Moq" Version="4.16.1" />
<PackageManagement Include="ncrontab" Version="3.3.1" />
<PackageManagement Include="Newtonsoft.Json" Version="13.0.1" />
<PackageManagement Include="NEST" Version="7.12.0" />
<PackageManagement Include="NJsonSchema" Version="10.5.2" />
<PackageManagement Include="NLog.Web.AspNetCore" Version="4.14.0" />
<PackageManagement Include="NodaTime" Version="3.0.7" />
Expand All @@ -54,5 +55,4 @@
<PackageManagement Include="Microsoft.SourceLink.GitHub" Version="1.0.0" />
<PackageManagement Include="ZString" Version="2.4.2" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion src/OrchardCore.Cms.Web/OrchardCore.Cms.Web.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project ToolsVersion="15.0" Sdk="Microsoft.NET.Sdk.Web">
<Project ToolsVersion="15.0" Sdk="Microsoft.NET.Sdk.Web">

<Import Project="..\OrchardCore.Build\Dependencies.props" />

Expand Down
7 changes: 5 additions & 2 deletions src/OrchardCore.Cms.Web/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@
// "ChangePasswordUrl": "ChangePassword",
// "ExternalLoginsUrl": "ExternalLogins"
//},

// Provides Elastic Connection
"OrchardCore_Elastic": {
"Url": "http://localhost:9200"
}
// WARNING: AutoSetup section given as an example for Development only, for Production use "Environment Variables" instead
//"OrchardCore_AutoSetup": {
// "AutoSetupPath": "",
Expand Down Expand Up @@ -118,4 +121,4 @@
// "Url": "/health/live"
//}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
},
"GraphQLContentTypePartSettings": {},
"HtmlBodyPartSettings": {},
"ContentIndexSettings": {}
"LuceneContentIndexSettings": {}
}
},
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using System.Collections.Generic;
using System.Reflection;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using OrchardCore.ContentManagement;
using OrchardCore.ContentManagement.Metadata;
using OrchardCore.ContentManagement.Metadata.Models;
using OrchardCore.Indexing;
using OrchardCore.Modules;

Expand Down Expand Up @@ -49,7 +51,9 @@ public async Task BuildIndexAsync(BuildIndexContext context)
var partActivator = _contentPartFactory.GetTypeActivator(partTypeName);
var part = (ContentPart)context.ContentItem.Get(partActivator.Type, partName);

var typePartIndexSettings = contentTypePartDefinition.GetSettings<ContentIndexSettings>();
MethodInfo ContentTypePartDefinitionMethod = typeof(ContentTypePartDefinition).GetMethod("GetSettings");
MethodInfo ContentTypePartDefinitionGeneric = ContentTypePartDefinitionMethod.MakeGenericMethod(context.Settings.GetType());
var typePartIndexSettings = (IContentIndexSettings)ContentTypePartDefinitionGeneric.Invoke(contentTypePartDefinition, null);

// Skip this part if it's not included in the index and it's not the default type part
if (contentTypeDefinition.Name != partTypeName && !typePartIndexSettings.Included)
Expand All @@ -63,7 +67,9 @@ await _partIndexHandlers.InvokeAsync((handler, part, contentTypePartDefinition,

foreach (var contentPartFieldDefinition in contentTypePartDefinition.PartDefinition.Fields)
{
var partFieldIndexSettings = contentPartFieldDefinition.GetSettings<ContentIndexSettings>();
MethodInfo ContentPartFieldDefinitionMethod = typeof(ContentPartFieldDefinition).GetMethod("GetSettings");
MethodInfo ContentPartFieldDefinitionGeneric = ContentPartFieldDefinitionMethod.MakeGenericMethod(context.Settings.GetType());
var partFieldIndexSettings = (IContentIndexSettings)ContentPartFieldDefinitionGeneric.Invoke(contentPartFieldDefinition, null);

if (!partFieldIndexSettings.Included)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@
"FacebookPluginPartSettings": {
"Liquid": "<div class=\"fb-customerchat\"\r\n page_id=\"<PAGE_ID>\">\r\n</div>"
},
"ContentIndexSettings": {}
"LuceneContentIndexSettings": {}
}
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public override async Task BuildIndexAsync(BagPart bagPart, BuildPartIndexContex
keys.Add($"{key}.{contentItem.ContentType}");
}

var buildIndexContext = new BuildIndexContext(context.DocumentIndex, contentItem, keys);
var buildIndexContext = new BuildIndexContext(context.DocumentIndex, contentItem, keys, context.Settings);

await contentItemIndexHandler.BuildIndexAsync(buildIndexContext);
}
Expand Down
2 changes: 1 addition & 1 deletion src/OrchardCore.Modules/OrchardCore.Lucene/AdminMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder)
.Permission(Permissions.ManageIndexes)
.LocalNav()))
.Add(S["Settings"], settings => settings
.Add(S["Search"], S["Search"].PrefixPosition(), entry => entry
.Add(S["Lucene"], S["Lucene"].PrefixPosition(), entry => entry
.Action("Index", "Admin", new { area = "OrchardCore.Settings", groupId = LuceneSettingsDisplayDriver.GroupId })
.Permission(Permissions.ManageIndexes)
.LocalNav()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace OrchardCore.Lucene.Drivers
{
public class LuceneSettingsDisplayDriver : SectionDisplayDriver<ISite, LuceneSettings>
{
public const string GroupId = "search";
public const string GroupId = "lucene";
private readonly LuceneIndexSettingsService _luceneIndexSettingsService;
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly IAuthorizationService _authorizationService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using OrchardCore.ContentPreview;
using OrchardCore.Environment.Shell.Scope;
using OrchardCore.Indexing;
using OrchardCore.Lucene.Model;
using OrchardCore.Modules;

namespace OrchardCore.Lucene.Handlers
Expand Down Expand Up @@ -106,7 +107,7 @@ private static async Task IndexingAsync(ShellScope scope, IEnumerable<ContentCon
}
else
{
var buildIndexContext = new BuildIndexContext(new DocumentIndex(contentItem.ContentItemId), contentItem, new string[] { contentItem.ContentType });
var buildIndexContext = new BuildIndexContext(new DocumentIndex(contentItem.ContentItemId), contentItem, new string[] { contentItem.ContentType }, new LuceneContentIndexSettings());
await contentItemIndexHandlers.InvokeAsync(x => x.BuildIndexAsync(buildIndexContext), logger);

await luceneIndexManager.DeleteDocumentsAsync(indexSettings.IndexName, new string[] { contentItem.ContentItemId });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
namespace OrchardCore.Indexing
using OrchardCore.Indexing;

namespace OrchardCore.Lucene.Model
{
/// <summary>
/// Represents the indexing settings for a content part or a field.
/// </summary>
public class ContentIndexSettings
public class LuceneContentIndexSettings : IContentIndexSettings
{
public bool Included { get; set; }
public bool Stored { get; set; }
Expand All @@ -26,4 +28,4 @@ public DocumentIndexOptions ToOptions()
return options;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ await shellScope.UsingAsync(async scope =>
var contentItem = await contentManager.GetAsync(task.ContentItemId);
if (contentItem != null)
{
publishedIndexContext = new BuildIndexContext(new DocumentIndex(task.ContentItemId), contentItem, new string[] { contentItem.ContentType });
publishedIndexContext = new BuildIndexContext(new DocumentIndex(task.ContentItemId), contentItem, new string[] { contentItem.ContentType }, new LuceneContentIndexSettings());
await indexHandlers.InvokeAsync(x => x.BuildIndexAsync(publishedIndexContext), _logger);
}
}
Expand All @@ -165,7 +165,7 @@ await shellScope.UsingAsync(async scope =>
var contentItem = await contentManager.GetAsync(task.ContentItemId, VersionOptions.Latest);
if (contentItem != null)
{
latestIndexContext = new BuildIndexContext(new DocumentIndex(task.ContentItemId), contentItem, new string[] { contentItem.ContentType });
latestIndexContext = new BuildIndexContext(new DocumentIndex(task.ContentItemId), contentItem, new string[] { contentItem.ContentType }, new LuceneContentIndexSettings());
await indexHandlers.InvokeAsync(x => x.BuildIndexAsync(latestIndexContext), _logger);
}
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using OrchardCore.DisplayManagement.ModelBinding;
using OrchardCore.DisplayManagement.Views;
using OrchardCore.Indexing;
using OrchardCore.Lucene.Model;

namespace OrchardCore.Lucene.Settings
{
Expand All @@ -27,9 +28,9 @@ public override async Task<IDisplayResult> EditAsync(ContentPartFieldDefinition
return null;
}

return Initialize<ContentIndexSettingsViewModel>("ContentIndexSettings_Edit", model =>
return Initialize<LuceneContentIndexSettingsViewModel>("LuceneContentIndexSettings_Edit", model =>
{
model.ContentIndexSettings = contentPartFieldDefinition.GetSettings<ContentIndexSettings>();
model.LuceneContentIndexSettings = contentPartFieldDefinition.GetSettings<LuceneContentIndexSettings>();
}).Location("Content:10");
}

Expand All @@ -40,13 +41,13 @@ public override async Task<IDisplayResult> UpdateAsync(ContentPartFieldDefinitio
return null;
}

var model = new ContentIndexSettingsViewModel();
var model = new LuceneContentIndexSettingsViewModel();

await context.Updater.TryUpdateModelAsync(model, Prefix);

context.Builder.WithSettings(model.ContentIndexSettings);
context.Builder.WithSettings(model.LuceneContentIndexSettings);

return await EditAsync(contentPartFieldDefinition, context.Updater);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using OrchardCore.DisplayManagement.ModelBinding;
using OrchardCore.DisplayManagement.Views;
using OrchardCore.Indexing;
using OrchardCore.Lucene.Model;

namespace OrchardCore.Lucene.Settings
{
Expand All @@ -27,9 +28,9 @@ public override async Task<IDisplayResult> EditAsync(ContentTypePartDefinition c
return null;
}

return Initialize<ContentIndexSettingsViewModel>("ContentIndexSettings_Edit", model =>
return Initialize<LuceneContentIndexSettingsViewModel>("LuceneContentIndexSettings_Edit", model =>
{
model.ContentIndexSettings = contentTypePartDefinition.GetSettings<ContentIndexSettings>();
model.LuceneContentIndexSettings = contentTypePartDefinition.GetSettings<LuceneContentIndexSettings>();
}).Location("Content:10");
}

Expand All @@ -40,13 +41,13 @@ public override async Task<IDisplayResult> UpdateAsync(ContentTypePartDefinition
return null;
}

var model = new ContentIndexSettingsViewModel();
var model = new LuceneContentIndexSettingsViewModel();

await context.Updater.TryUpdateModelAsync(model, Prefix);

context.Builder.WithSettings(model.ContentIndexSettings);
context.Builder.WithSettings(model.LuceneContentIndexSettings);

return await EditAsync(contentTypePartDefinition, context.Updater);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using OrchardCore.Lucene.Model;

namespace OrchardCore.Lucene.Settings
{
public class LuceneContentIndexSettingsViewModel
{
public LuceneContentIndexSettings LuceneContentIndexSettings { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
int endIndex = startIndex + Model.Indexes.Count() - 1;
}

<zone Name="Title"><h1>@RenderTitleSegments(T["Indices"])</h1></zone>
<zone Name="Title"><h1>@RenderTitleSegments(T["Lucene Indices"])</h1></zone>

@* the form is necessary to generate and antiforgery token for the delete action *@
<form asp-action="Index" method="post" class="no-multisubmit">
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
@model OrchardCore.Lucene.Settings.LuceneContentIndexSettingsViewModel
<h4>Lucene</h4>

<div class="form-group">
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" asp-for="LuceneContentIndexSettings.Included" data-toggle="collapse" data-target="#lucene-index-settings" checked="@Model.LuceneContentIndexSettings.Included" />
<label class="custom-control-label" asp-for="LuceneContentIndexSettings.Included">@T["Include this element in the index"]</label>
<span class="hint dashed">@T["Check to include the value of this element in the index."]</span>
</div>
<div id="lucene-index-settings" class="collapse">

<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" asp-for="LuceneContentIndexSettings.Stored" checked="@Model.LuceneContentIndexSettings.Stored" />
<label class="custom-control-label" asp-for="LuceneContentIndexSettings.Stored">@T["Stored"]</label>
<span class="hint dashed">@T["Check to be able to retrieve the value from the index."]</span>
</div>

<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" asp-for="LuceneContentIndexSettings.Analyzed" checked="@Model.LuceneContentIndexSettings.Analyzed" />
<label class="custom-control-label" asp-for="LuceneContentIndexSettings.Analyzed">@T["Analyzed"]</label>
<span class="hint dashed">@T["Check to analyze the value as readable text."]</span>
</div>
</div>
</div>

Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"DisplayAllContentTypes": true,
"DisplayedContentTypes": []
},
"ContentIndexSettings": {}
"LuceneContentIndexSettings": {}
}
}
]
Expand Down
Loading

0 comments on commit 55819e6

Please sign in to comment.