Skip to content

Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.

Remove fulltext settings

KrzysztofPajak540b11100953
diff --git a/src/Business/Grand.Business.Catalog/Queries/Handlers/GetSearchProductsQueryHandler.cs b/src/Business/Grand.Business.Catalog/Queries/Handlers/GetSearchProductsQueryHandler.cs
index 2d05c0664..3415cb902 100644
--- a/src/Business/Grand.Business.Catalog/Queries/Handlers/GetSearchProductsQueryHandler.cs
+++ b/src/Business/Grand.Business.Catalog/Queries/Handlers/GetSearchProductsQueryHandler.cs
@@ -1,7 +1,6 @@
using Grand.Business.Catalog.Interfaces.Products;
using Grand.Domain;
using Grand.Domain.Catalog;
-using Grand.Domain.Common;
using Grand.Domain.Customers;
using Grand.Domain.Data;
using Grand.SharedKernel.Extensions;
@@ -23,19 +22,15 @@ namespace Grand.Business.Catalog.Queries.Handlers
private readonly ISpecificationAttributeService _specificationAttributeService;
private readonly CatalogSettings _catalogSettings;
- private readonly FullTextSettings _fullTextSettings;
public GetSearchProductsQueryHandler(
IRepository<Product> productRepository,
ISpecificationAttributeService specificationAttributeService,
- CatalogSettings catalogSettings,
- FullTextSettings fullTextSettings)
+ CatalogSettings catalogSettings)
{
_productRepository = productRepository;
_specificationAttributeService = specificationAttributeService;
-
_catalogSettings = catalogSettings;
- _fullTextSettings = fullTextSettings;
}
public async Task<(IPagedList<Product> products, IList<string> filterableSpecificationAttributeOptionIds)>
@@ -149,39 +144,31 @@ namespace Grand.Business.Catalog.Queries.Handlers
//searching by keyword
if (!String.IsNullOrWhiteSpace(request.Keywords))
{
- if (_fullTextSettings.UseFullTextSearch)
- {
- request.Keywords = "\"" + request.Keywords + "\"";
- request.Keywords = request.Keywords.Replace("+", "\" \"");
- request.Keywords = request.Keywords.Replace(" ", "\" \"");
- filter &= builder.Text(request.Keywords);
- }
+
+ if (!request.SearchDescriptions)
+ filter &= builder.Where(p =>
+ p.Name.ToLower().Contains(request.Keywords.ToLower())
+ ||
+ p.Locales.Any(x => x.LocaleKey == "Name" && x.LocaleValue != null && x.LocaleValue.ToLower().Contains(request.Keywords.ToLower()))
+ ||
+ (request.SearchSku && p.Sku.ToLower().Contains(request.Keywords.ToLower()))
+ );
else
{
- if (!request.SearchDescriptions)
- filter &= builder.Where(p =>
- p.Name.ToLower().Contains(request.Keywords.ToLower())
+ filter &= builder.Where(p =>
+ (p.Name != null && p.Name.ToLower().Contains(request.Keywords.ToLower()))
+ ||
+ (p.ShortDescription != null && p.ShortDescription.ToLower().Contains(request.Keywords.ToLower()))
||
- p.Locales.Any(x => x.LocaleKey == "Name" && x.LocaleValue != null && x.LocaleValue.ToLower().Contains(request.Keywords.ToLower()))
+ (p.FullDescription != null && p.FullDescription.ToLower().Contains(request.Keywords.ToLower()))
+ ||
+ (p.Locales.Any(x => x.LocaleValue != null && x.LocaleValue.ToLower().Contains(request.Keywords.ToLower())))
||
(request.SearchSku && p.Sku.ToLower().Contains(request.Keywords.ToLower()))
);
- else
- {
- filter &= builder.Where(p =>
- (p.Name != null && p.Name.ToLower().Contains(request.Keywords.ToLower()))
- ||
- (p.ShortDescription != null && p.ShortDescription.ToLower().Contains(request.Keywords.ToLower()))
- ||
- (p.FullDescription != null && p.FullDescription.ToLower().Contains(request.Keywords.ToLower()))
- ||
- (p.Locales.Any(x => x.LocaleValue != null && x.LocaleValue.ToLower().Contains(request.Keywords.ToLower())))
- ||
- (request.SearchSku && p.Sku.ToLower().Contains(request.Keywords.ToLower()))
- );
- }
}
+
}
if (!request.ShowHidden && !CommonHelper.IgnoreAcl)
diff --git a/src/Business/Grand.Business.Marketing/Services/Knowledgebase/KnowledgebaseService.cs b/src/Business/Grand.Business.Marketing/Services/Knowledgebase/KnowledgebaseService.cs
index 21057ba85..2ec32e083 100644
--- a/src/Business/Grand.Business.Marketing/Services/Knowledgebase/KnowledgebaseService.cs
+++ b/src/Business/Grand.Business.Marketing/Services/Knowledgebase/KnowledgebaseService.cs
@@ -26,7 +26,6 @@ namespace Grand.Business.Marketing.Services.Knowledgebase
private readonly IMediator _mediator;
private readonly IWorkContext _workContext;
private readonly ICacheBase _cacheBase;
- private readonly FullTextSettings _fullTextSettings;
/// <summary>
/// Ctor
@@ -37,8 +36,7 @@ namespace Grand.Business.Marketing.Services.Knowledgebase
IRepository<KnowledgebaseArticleComment> articleCommentRepository,
IMediator mediator,
IWorkContext workContext,
- ICacheBase cacheBase,
- FullTextSettings fullTextSettings
+ ICacheBase cacheBase
)
{
_knowledgebaseCategoryRepository = knowledgebaseCategoryRepository;
@@ -47,7 +45,6 @@ namespace Grand.Business.Marketing.Services.Knowledgebase
_mediator = mediator;
_workContext = workContext;
_cacheBase = cacheBase;
- _fullTextSettings = fullTextSettings;
}
/// <summary>
diff --git a/src/Business/Grand.Business.System/Commands/Handlers/Common/UseFullTextSearchCommandHandler.cs b/src/Business/Grand.Business.System/Commands/Handlers/Common/UseFullTextSearchCommandHandler.cs
deleted file mode 100644
index 4a3cc2efc..000000000
--- a/src/Business/Grand.Business.System/Commands/Handlers/Common/UseFullTextSearchCommandHandler.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-using Grand.Business.System.Commands.Models.Common;
-using Grand.Domain.Catalog;
-using Grand.Domain.Data;
-using MediatR;
-using MongoDB.Driver;
-using System.Threading;
-using System.Threading.Tasks;
-
-namespace Grand.Business.System.Commands.Handlers.Common
-{
- public class UseFullTextSearchCommandHandler : IRequestHandler<UseFullTextSearchCommand, bool>
- {
- private readonly IRepository<Product> _repositoryProduct;
-
- public UseFullTextSearchCommandHandler(IRepository<Product> repositoryProduct)
- {
- _repositoryProduct = repositoryProduct;
- }
-
- public async Task<bool> Handle(UseFullTextSearchCommand request, CancellationToken cancellationToken)
- {
- if (request.UseFullTextSearch)
- {
- var indexOption = new CreateIndexOptions() { Name = "ProductText" };
- indexOption.Collation = new Collation("simple");
- await _repositoryProduct.Collection.Indexes.CreateOneAsync(new CreateIndexModel<Product>((Builders<Product>.IndexKeys.Text("$**")), indexOption));
- }
- else
- {
- await _repositoryProduct.Collection.Indexes.DropOneAsync("ProductText");
- }
-
- return true;
- }
- }
-}
diff --git a/src/Business/Grand.Business.System/Commands/Models/Common/UseFullTextSearchCommand.cs b/src/Business/Grand.Business.System/Commands/Models/Common/UseFullTextSearchCommand.cs
deleted file mode 100644
index c869b14e4..000000000
--- a/src/Business/Grand.Business.System/Commands/Models/Common/UseFullTextSearchCommand.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-using MediatR;
-
-namespace Grand.Business.System.Commands.Models.Common
-{
- public class UseFullTextSearchCommand : IRequest<bool>
- {
- public bool UseFullTextSearch { get; set; }
- }
-}
diff --git a/src/Core/Grand.Domain/Common/FullTextSettings.cs b/src/Core/Grand.Domain/Common/FullTextSettings.cs
deleted file mode 100644
index be37122b1..000000000
--- a/src/Core/Grand.Domain/Common/FullTextSettings.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-using Grand.Domain.Configuration;
-
-namespace Grand.Domain.Common
-{
- public class FullTextSettings : ISettings
- {
- public bool UseFullTextSearch { get; set; }
- }
-}
\ No newline at end of file
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Setting/GeneralCommon.TabFullTextSettings.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Setting/GeneralCommon.TabFullTextSettings.cshtml
deleted file mode 100644
index ed395242b..000000000
--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Setting/GeneralCommon.TabFullTextSettings.cshtml
+++ /dev/null
@@ -1,20 +0,0 @@
-@model GeneralCommonSettingsModel
-
-<div class="form-horizontal">
- <div class="form-body"></div>
- <div class="note note-info">
- @if (Model.FullTextSettings.Enabled)
- {
- @Loc["Admin.Settings.GeneralCommon.FullTextSettings.CurrenlyEnabled"]
- }
- else
- {
- @Loc["Admin.Settings.GeneralCommon.FullTextSettings.CurrenlyDisabled"]
- }
- </div>
- <div class="form-group">
- <div class="">
- <input type="submit" name="togglefulltext" asp-action="ToggleFullText" value="@(Model.FullTextSettings.Enabled ? Loc["Admin.Settings.GeneralCommon.FullTextSettings.Disable"] : Loc["Admin.Settings.GeneralCommon.FullTextSettings.Enable"])" class="k-button" />
- </div>
- </div>
-</div>
\ No newline at end of file
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Setting/GeneralCommon.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Setting/GeneralCommon.cshtml
index 3d3de0998..f8fe3f593 100644
--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Setting/GeneralCommon.cshtml
+++ b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Setting/GeneralCommon.cshtml
@@ -61,13 +61,6 @@
</div>
</content>
</tabstrip-item>
- <tabstrip-item text="@Loc["Admin.Settings.GeneralCommon.FullTextSettings"]" tab-index="4">
- <content>
- <div>
- <partial name="GeneralCommon.TabFullTextSettings" model="Model" />
- </div>
- </content>
- </tabstrip-item>
<tabstrip-item text="@Loc["Admin.Settings.GeneralCommon.GoogleAnalytics"]" tab-index="5">
<content>
<div>
diff --git a/src/Web/Grand.Web.Admin/Controllers/SettingController.cs b/src/Web/Grand.Web.Admin/Controllers/SettingController.cs
index eed21e931..17e8587d3 100644
--- a/src/Web/Grand.Web.Admin/Controllers/SettingController.cs
+++ b/src/Web/Grand.Web.Admin/Controllers/SettingController.cs
@@ -11,7 +11,6 @@ using Grand.Business.Common.Interfaces.Stores;
using Grand.Business.Common.Services.Security;
using Grand.Business.Customers.Interfaces;
using Grand.Business.Storage.Interfaces;
-using Grand.Business.System.Commands.Models.Common;
using Grand.Domain.AdminSearch;
using Grand.Domain.Blogs;
using Grand.Domain.Catalog;
@@ -155,8 +154,7 @@ namespace Grand.Web.Admin.Controllers
var blogSettings = _settingService.LoadSetting<BlogSettings>(storeScope);
var newsSettings = _settingService.LoadSetting<NewsSettings>(storeScope);
var knowledgebaseSettings = _settingService.LoadSetting<KnowledgebaseSettings>(storeScope);
- var model = new ContentSettingsModel()
- {
+ var model = new ContentSettingsModel() {
BlogSettings = blogSettings.ToModel(),
NewsSettings = newsSettings.ToModel()
};
@@ -307,16 +305,14 @@ namespace Grand.Web.Admin.Controllers
var model = new List<SortOptionModel>();
foreach (int option in Enum.GetValues(typeof(ProductSortingEnum)))
{
- model.Add(new SortOptionModel()
- {
+ model.Add(new SortOptionModel() {
Id = option,
Name = ((ProductSortingEnum)option).GetTranslationEnum(_translationService, _workContext),
IsActive = !catalogSettings.ProductSortingEnumDisabled.Contains(option),
DisplayOrder = catalogSettings.ProductSortingEnumDisplayOrder.TryGetValue(option, out int value) ? value : option
});
}
- var gridModel = new DataSourceResult
- {
+ var gridModel = new DataSourceResult {
Data = model.OrderBy(option => option.DisplayOrder),
Total = model.Count
};
@@ -352,8 +348,7 @@ namespace Grand.Web.Admin.Controllers
var orderSettings = _settingService.LoadSetting<OrderSettings>(storeScope);
var shoppingCartSettings = _settingService.LoadSetting<ShoppingCartSettings>(storeScope);
- var model = new SalesSettingsModel()
- {
+ var model = new SalesSettingsModel() {
LoyaltyPointsSettings = loyaltyPointsSettings.ToModel(),
OrderSettings = orderSettings.ToModel(),
ShoppingCartSettings = shoppingCartSettings.ToModel(),
@@ -437,8 +432,7 @@ namespace Grand.Web.Admin.Controllers
public async Task<IActionResult> MerchandiseReturnReasonList(DataSourceRequest command)
{
var reasons = await _merchandiseReturnService.GetAllMerchandiseReturnReasons();
- var gridModel = new DataSourceResult
- {
+ var gridModel = new DataSourceResult {
Data = reasons.Select(x => x.ToModel()),
Total = reasons.Count
};
@@ -536,8 +530,7 @@ namespace Grand.Web.Admin.Controllers
public async Task<IActionResult> MerchandiseReturnActionList(DataSourceRequest command)
{
var actions = await _merchandiseReturnService.GetAllMerchandiseReturnActions();
- var gridModel = new DataSourceResult
- {
+ var gridModel = new DataSourceResult {
Data = actions.Select(x => x.ToModel()),
Total = actions.Count
};
@@ -714,8 +707,7 @@ namespace Grand.Web.Admin.Controllers
var addressSettings = _settingService.LoadSetting<AddressSettings>(storeScope);
//merge settings
- var model = new CustomerSettingsModel
- {
+ var model = new CustomerSettingsModel {
CustomerSettings = customerSettings.ToModel(),
AddressSettings = addressSettings.ToModel()
};
@@ -765,8 +757,7 @@ namespace Grand.Web.Admin.Controllers
foreach (TimeZoneInfo timeZone in _dateTimeService.GetSystemTimeZones())
{
var name = iswindows ? timeZone.DisplayName : $"{timeZone.StandardName} ({timeZone.Id})";
- model.DateTimeSettings.AvailableTimeZones.Add(new SelectListItem
- {
+ model.DateTimeSettings.AvailableTimeZones.Add(new SelectListItem {
Text = name,
Value = timeZone.Id,
Selected = timeZone.Id.Equals(dateTimeSettings.DefaultStoreTimeZoneId, StringComparison.OrdinalIgnoreCase)
@@ -779,8 +770,7 @@ namespace Grand.Web.Admin.Controllers
model.StoreInformationSettings.DefaultStoreTheme = storeInformationSettings.DefaultStoreTheme;
model.StoreInformationSettings.AvailableStoreThemes = _themeProvider
.GetConfigurations()
- .Select(x => new GeneralCommonSettingsModel.StoreInformationSettingsModel.ThemeConfigurationModel
- {
+ .Select(x => new GeneralCommonSettingsModel.StoreInformationSettingsModel.ThemeConfigurationModel {
ThemeTitle = x.Title,
ThemeName = x.Name,
ThemeVersion = x.Version,
@@ -871,10 +861,6 @@ namespace Grand.Web.Admin.Controllers
model.PdfSettings.InvoiceHeaderText = pdfSettings.InvoiceHeaderText;
model.PdfSettings.InvoiceFooterText = pdfSettings.InvoiceFooterText;
- //full-text support
- var fullTextSettings = _settingService.LoadSetting<FullTextSettings>();
- model.FullTextSettings.Enabled = fullTextSettings.UseFullTextSearch;
-
//google analytics
model.GoogleAnalyticsSettings.GaprivateKey = googleAnalyticsSettings.gaprivateKey;
model.GoogleAnalyticsSettings.GaserviceAccountEmail = googleAnalyticsSettings.gaserviceAccountEmail;
@@ -1041,46 +1027,12 @@ namespace Grand.Web.Admin.Controllers
return RedirectToAction("GeneralCommon");
}
- [HttpPost]
- public async Task<IActionResult> ToggleFullText()
- {
- //https://docs.mongodb.com/manual/reference/text-search-languages/#text-search-languages
- var fullTextSettings = _settingService.LoadSetting<FullTextSettings>();
- try
- {
- if (fullTextSettings.UseFullTextSearch)
- {
- await _mediator.Send(new UseFullTextSearchCommand() { UseFullTextSearch = false });
- fullTextSettings.UseFullTextSearch = false;
- await _settingService.SaveSetting(fullTextSettings);
- Success(_translationService.GetResource("Admin.Settings.GeneralCommon.FullTextSettings.Disabled"));
- }
- else
- {
- await _mediator.Send(new UseFullTextSearchCommand() { UseFullTextSearch = true });
- fullTextSettings.UseFullTextSearch = true;
- await _settingService.SaveSetting(fullTextSettings);
- Success(_translationService.GetResource("Admin.Settings.GeneralCommon.FullTextSettings.Enabled"));
- }
- }
- catch (Exception exc)
- {
- Error(exc);
- }
-
- //selected tab
- await SaveSelectedTabIndex();
-
- return RedirectToAction("GeneralCommon");
- }
-
public async Task<IActionResult> PushNotifications()
{
var storeScope = await GetActiveStore(_storeService, _workContext);
var settings = _settingService.LoadSetting<PushNotificationsSettings>(storeScope);
- var model = new ConfigurationModel
- {
+ var model = new ConfigurationModel {
AllowGuestNotifications = settings.AllowGuestNotifications,
AuthDomain = settings.AuthDomain,
DatabaseUrl = settings.DatabaseUrl,
@@ -1174,8 +1126,7 @@ namespace Grand.Web.Admin.Controllers
public IActionResult AdminSearch()
{
var settings = _settingService.LoadSetting<AdminSearchSettings>();
- var model = new AdminSearchSettingsModel
- {
+ var model = new AdminSearchSettingsModel {
SearchInBlogs = settings.SearchInBlogs,
SearchInCategories = settings.SearchInCategories,
SearchInCustomers = settings.SearchInCustomers,
diff --git a/src/Web/Grand.Web.Admin/Models/Settings/GeneralCommonSettingsModel.cs b/src/Web/Grand.Web.Admin/Models/Settings/GeneralCommonSettingsModel.cs
index 67698c6ab..f50614335 100644
--- a/src/Web/Grand.Web.Admin/Models/Settings/GeneralCommonSettingsModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Settings/GeneralCommonSettingsModel.cs
@@ -16,7 +16,6 @@ namespace Grand.Web.Admin.Models.Settings
SeoSettings = new SeoSettingsModel();
SecuritySettings = new SecuritySettingsModel();
PdfSettings = new PdfSettingsModel();
- FullTextSettings = new FullTextSettingsModel();
GoogleAnalyticsSettings = new GoogleAnalyticsSettingsModel();
DisplayMenuSettings = new DisplayMenuSettingsModel();
}
@@ -26,7 +25,6 @@ namespace Grand.Web.Admin.Models.Settings
public SeoSettingsModel SeoSettings { get; set; }
public SecuritySettingsModel SecuritySettings { get; set; }
public PdfSettingsModel PdfSettings { get; set; }
- public FullTextSettingsModel FullTextSettings { get; set; }
public GoogleAnalyticsSettingsModel GoogleAnalyticsSettings { get; set; }
public DisplayMenuSettingsModel DisplayMenuSettings { get; set; }
@@ -283,12 +281,6 @@ namespace Grand.Web.Admin.Models.Settings
public string InvoiceFooterText { get; set; }
}
- public partial class FullTextSettingsModel : BaseModel
- {
- public bool Enabled { get; set; }
-
- }
-
public partial class GoogleAnalyticsSettingsModel : BaseModel
{
[GrandResourceDisplayName("Admin.Settings.GeneralCommon.GoogleAnalyticsPrivateKey")]
diff --git a/src/Web/Grand.Web/App_Data/Resources/DefaultLanguage.xml b/src/Web/Grand.Web/App_Data/Resources/DefaultLanguage.xml
index 43674f8c9..cec13491f 100644
--- a/src/Web/Grand.Web/App_Data/Resources/DefaultLanguage.xml
+++ b/src/Web/Grand.Web/App_Data/Resources/DefaultLanguage.xml
@@ -11134,36 +11134,6 @@
<Resource Name="Admin.Settings.GeneralCommon.FacebookLink">
<Value>Facebook page URL</Value>
</Resource>
- <Resource Name="Admin.Settings.GeneralCommon.FullTextSettings">
- <Value>Full-Text settings</Value>
- </Resource>
- <Resource Name="Admin.Settings.GeneralCommon.FullTextSettings.CurrenlyDisabled">
- <Value>Full-Text is disabled</Value>
- </Resource>
- <Resource Name="Admin.Settings.GeneralCommon.FullTextSettings.CurrenlyEnabled">
- <Value>Full-Text is enabled</Value>
- </Resource>
- <Resource Name="Admin.Settings.GeneralCommon.FullTextSettings.Disable">
- <Value>Disable Full-Text</Value>
- </Resource>
- <Resource Name="Admin.Settings.GeneralCommon.FullTextSettings.Disabled">
- <Value>Full-Text support has been disabled successfully.</Value>
- </Resource>
- <Resource Name="Admin.Settings.GeneralCommon.FullTextSettings.Enable">
- <Value>Enable Full-Text</Value>
- </Resource>
- <Resource Name="Admin.Settings.GeneralCommon.FullTextSettings.Enabled">
- <Value>Full-Text support has been enabled successfully.</Value>
- </Resource>
- <Resource Name="Admin.Settings.GeneralCommon.FullTextSettings.NoiseWords">
- <Value>To prevent a full-text index from becoming bloated, Microsoft SQL Server has a mechanism that discards commonly occurring words that do not help the search. These words are called noise words, or stop words. Noise words are listed in the locale specific noise word files. For example, in the English locale, words such as "a," "and," "is," and "the" are in the English noise word file and are left out of the full-text index since they are empirically known to be useless to a search. Please contact your SQL Server administrator to get more information about it.</Value>
- </Resource>
- <Resource Name="Admin.Settings.GeneralCommon.FullTextSettings.NotSupported">
- <Value>Full-Text is not supported by your database</Value>
- </Resource>
- <Resource Name="Admin.Settings.GeneralCommon.FullTextSettings.Supported">
- <Value>Full-Text is supported by your database</Value>
- </Resource>
<Resource Name="Admin.Settings.GeneralCommon.GenerateProductMetaDescription">
<Value>If not provided, generate product META description automatically</Value>
</Resource>
@@ -13689,15 +13659,6 @@
<Resource Name="Enums.Grand.Domain.Catalog.SpecificationAttributeType.Option">
<Value>Option</Value>
</Resource>
- <Resource Name="Enums.Grand.Domain.Common.FulltextSearchMode.And">
- <Value>Using CONTAINS and AND with prefix_term</Value>
- </Resource>
- <Resource Name="Enums.Grand.Domain.Common.FulltextSearchMode.ExactMatch">
- <Value>Exact match (using CONTAINS with prefix_term)</Value>
- </Resource>
- <Resource Name="Enums.Grand.Domain.Common.FulltextSearchMode.Or">
- <Value>Using CONTAINS and OR with prefix_term</Value>
- </Resource>
<Resource Name="Enums.Grand.Domain.Customers.CustomerNameFormat.Emails">
<Value>Show emails</Value>
</Resource>