add search reindex capability

This commit is contained in:
sbwalker
2024-08-10 10:01:52 -04:00
parent 44a3db417b
commit 35f873a342
10 changed files with 75 additions and 39 deletions

View File

@ -186,18 +186,21 @@ namespace Oqtane.Infrastructure
if (string.IsNullOrEmpty(searchContent.Title))
{
searchContent.Title = string.Empty;
if (!string.IsNullOrEmpty(pageModule.Title))
{
searchContent.Title = pageModule.Title;
}
else if (pageModule.Page != null)
if (pageModule.Page != null)
{
searchContent.Title = !string.IsNullOrEmpty(pageModule.Page.Title) ? pageModule.Page.Title : pageModule.Page.Name;
}
else
{
searchContent.Title = pageModule.Title;
}
}
if (searchContent.Description == null)
{
searchContent.Description = (searchContent.Title != pageModule.Title) ? pageModule.Title : string.Empty;
}
if (searchContent.Description == null) { searchContent.Description = string.Empty;}
if (searchContent.Body == null) { searchContent.Body = string.Empty; }
if (string.IsNullOrEmpty(searchContent.Url))

View File

@ -57,6 +57,7 @@ namespace Oqtane.Modules.Admin.Files.Manager
EntityName = EntityNames.File,
EntityId = file.FileId.ToString(),
Title = path,
Description = "",
Body = body,
Url = $"{Constants.FileUrl}{folder.Path}{file.Name}",
Permissions = $"{EntityNames.Folder}:{folder.FolderId}",

View File

@ -37,12 +37,10 @@ namespace Oqtane.Services
var searchProvider = GetSearchProvider(searchQuery.SiteId);
var searchResults = await searchProvider.GetSearchResultsAsync(searchQuery);
// security trim results
// security trim results and aggregate by Url
var results = searchResults.Where(item => HasViewPermission(item, searchQuery))
.OrderBy(item => item.Url).ThenByDescending(item => item.Score);
// aggegrate by Url
results.GroupBy(group => group.Url)
.OrderBy(item => item.Url).ThenByDescending(item => item.Score)
.GroupBy(group => group.Url)
.Select(result => new SearchResult
{
SearchContentId = result.First().SearchContentId,