#4303: add search function.
This commit is contained in:
45
Oqtane.Shared/Models/SearchDocument.cs
Normal file
45
Oqtane.Shared/Models/SearchDocument.cs
Normal file
@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Text.Json;
|
||||
namespace Oqtane.Models
|
||||
{
|
||||
public class SearchDocument : ModelBase
|
||||
{
|
||||
public int SearchDocumentId { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public string UniqueKey => $"{IndexerName}:{EntryId}";
|
||||
|
||||
public int EntryId { get; set; }
|
||||
|
||||
public string IndexerName { get; set; }
|
||||
|
||||
public int SiteId { get; set; }
|
||||
|
||||
public string Title { get; set; }
|
||||
|
||||
public string Description { get; set; }
|
||||
|
||||
public string Body { get; set; }
|
||||
|
||||
public string Url { get; set; }
|
||||
|
||||
public DateTime ModifiedTime { get; set; }
|
||||
|
||||
public bool IsActive { get; set; }
|
||||
|
||||
public string AdditionalContent { get; set; }
|
||||
|
||||
public string LanguageCode { get; set; }
|
||||
|
||||
public IList<SearchDocumentTag> Tags { get; set; }
|
||||
|
||||
public IList<SearchDocumentProperty> Properties { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return JsonSerializer.Serialize(this);
|
||||
}
|
||||
}
|
||||
}
|
17
Oqtane.Shared/Models/SearchDocumentProperty.cs
Normal file
17
Oqtane.Shared/Models/SearchDocumentProperty.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Oqtane.Models
|
||||
{
|
||||
public class SearchDocumentProperty
|
||||
{
|
||||
[Key]
|
||||
public int PropertyId { get; set; }
|
||||
|
||||
public int SearchDocumentId { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
public string Value { get; set; }
|
||||
}
|
||||
}
|
14
Oqtane.Shared/Models/SearchDocumentTag.cs
Normal file
14
Oqtane.Shared/Models/SearchDocumentTag.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Oqtane.Models
|
||||
{
|
||||
public class SearchDocumentTag
|
||||
{
|
||||
[Key]
|
||||
public int TagId { get; set; }
|
||||
|
||||
public int SearchDocumentId { get; set; }
|
||||
|
||||
public string Tag { get; set; }
|
||||
}
|
||||
}
|
37
Oqtane.Shared/Models/SearchQuery.cs
Normal file
37
Oqtane.Shared/Models/SearchQuery.cs
Normal file
@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Oqtane.Shared;
|
||||
|
||||
namespace Oqtane.Models
|
||||
{
|
||||
public class SearchQuery
|
||||
{
|
||||
public int SiteId { get; set; }
|
||||
|
||||
public Alias Alias { get; set; }
|
||||
|
||||
public User User { get; set; }
|
||||
|
||||
public string Keywords { get; set; }
|
||||
|
||||
public IList<string> Sources { get; set; } = new List<string>();
|
||||
|
||||
public DateTime BeginModifiedTimeUtc { get; set; }
|
||||
|
||||
public DateTime EndModifiedTimeUtc { get; set; }
|
||||
|
||||
public IList<string> Tags { get; set; } = new List<string>();
|
||||
|
||||
public IDictionary<string, string> Properties { get; set; } = new Dictionary<string, string>();
|
||||
|
||||
public int PageIndex { get; set; }
|
||||
|
||||
public int PageSize { get; set; }
|
||||
|
||||
public SearchSortFields SortField { get; set; }
|
||||
|
||||
public SearchSortDirections SortDirection { get; set; }
|
||||
|
||||
public int BodySnippetLength { get; set;} = 255;
|
||||
}
|
||||
}
|
11
Oqtane.Shared/Models/SearchResult.cs
Normal file
11
Oqtane.Shared/Models/SearchResult.cs
Normal file
@ -0,0 +1,11 @@
|
||||
namespace Oqtane.Models
|
||||
{
|
||||
public class SearchResult : SearchDocument
|
||||
{
|
||||
public float Score { get; set; }
|
||||
|
||||
public string DisplayScore { get; set; }
|
||||
|
||||
public string Snippet { get; set; }
|
||||
}
|
||||
}
|
11
Oqtane.Shared/Models/SearchResults.cs
Normal file
11
Oqtane.Shared/Models/SearchResults.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Oqtane.Models
|
||||
{
|
||||
public class SearchResults
|
||||
{
|
||||
public IList<SearchResult> Results { get; set; }
|
||||
|
||||
public int TotalResults { get; set; }
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user