-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #984 from IgorAlymov/SITKO-CORE-T-18
feat(opensearch): added solution for searching with OpenSearch
- Loading branch information
Showing
12 changed files
with
555 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using JetBrains.Annotations; | ||
using Microsoft.Extensions.Hosting; | ||
using Sitko.Core.App; | ||
|
||
namespace Sitko.Core.Search.OpenSearch; | ||
|
||
[PublicAPI] | ||
public static class ApplicationExtensions | ||
{ | ||
public static IHostApplicationBuilder AddOpenSearch(this IHostApplicationBuilder hostApplicationBuilder, | ||
Action<IApplicationContext, OpenSearchModuleOptions> configure, | ||
string? optionsKey = null) | ||
{ | ||
hostApplicationBuilder.GetSitkoCore().AddOpenSearch(configure, optionsKey); | ||
return hostApplicationBuilder; | ||
} | ||
|
||
public static IHostApplicationBuilder AddOpenSearch(this IHostApplicationBuilder hostApplicationBuilder, | ||
Action<OpenSearchModuleOptions>? configure = null, | ||
string? optionsKey = null) | ||
{ | ||
hostApplicationBuilder.GetSitkoCore().AddOpenSearch(configure, optionsKey); | ||
return hostApplicationBuilder; | ||
} | ||
|
||
public static ISitkoCoreApplicationBuilder AddOpenSearch(this ISitkoCoreApplicationBuilder applicationBuilder, | ||
Action<IApplicationContext, OpenSearchModuleOptions> configure, | ||
string? optionsKey = null) => | ||
applicationBuilder.AddModule<OpenSearchModule, OpenSearchModuleOptions>(configure, optionsKey); | ||
|
||
public static ISitkoCoreApplicationBuilder AddOpenSearch(this ISitkoCoreApplicationBuilder applicationBuilder, | ||
Action<OpenSearchModuleOptions>? configure = null, | ||
string? optionsKey = null) => | ||
applicationBuilder.AddModule<OpenSearchModule, OpenSearchModuleOptions>(configure, optionsKey); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
namespace Sitko.Core.Search.OpenSearch; | ||
|
||
public class OpenSearchModule : SearchModule<OpenSearchModuleOptions> | ||
{ | ||
public override string OptionsKey => "Search:OpenSearch"; | ||
|
||
protected override void ConfigureSearch(IServiceCollection services) => | ||
services.AddScoped(typeof(ISearcher<>), typeof(OpenSearchSearcher<>)); | ||
} |
20 changes: 20 additions & 0 deletions
20
src/Sitko.Core.Search.OpenSearch/OpenSearchModuleOptions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using FluentValidation; | ||
|
||
namespace Sitko.Core.Search.OpenSearch; | ||
|
||
public class OpenSearchModuleOptions : SearchModuleOptions | ||
{ | ||
public string Prefix { get; set; } = ""; | ||
public string Url { get; set; } = "http://localhost:9200"; | ||
public string Login { get; set; } = ""; | ||
public string Password { get; set; } = ""; | ||
public bool EnableClientLogging { get; set; } | ||
public bool DisableCertificatesValidation { get; set; } | ||
public string CustomStemmer { get; set; } = ""; | ||
} | ||
|
||
public class OpenSearchModuleOptionsValidator : AbstractValidator<OpenSearchModuleOptions> | ||
{ | ||
public OpenSearchModuleOptionsValidator() => | ||
RuleFor(o => o.Url).NotEmpty().WithMessage("OpenSearch url is empty"); | ||
} |
Oops, something went wrong.