add search reindex capability
This commit is contained in:
@ -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))
|
||||
|
@ -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}",
|
||||
|
@ -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,
|
||||
|
Reference in New Issue
Block a user