using Nuuru.Server.DTOs;
using Nuuru.Server.DTOs.Booru;
namespace Nuuru.Server.Services.Search;
///
/// Service for searching booru posts with advanced query syntax.
///
public interface IBooruSearchService
{
///
/// Searches posts using the query string with full syntax support.
///
/// The search query (tags, meta-tags, operators)
/// Page number (1-based)
/// Number of results per page
/// Paginated search results with metadata
Task SearchPostsAsync(string? query, int page = 1, int pageSize = 20);
///
/// Builds an EF Core query from the search string without executing it.
///
/// The search query
/// Queryable of posts
Task> BuildQueryAsync(string? query);
///
/// Validates a search query without executing it.
///
/// The query to validate
/// Validation result with any errors
SearchValidationResult ValidateQuery(string query);
}
///
/// Result of a search operation.
///
public class SearchResult
{
///
/// Paginated post results.
///
public PagedResult Posts { get; set; } = new();
///
/// Search metadata and diagnostics.
///
public SearchMetadata Metadata { get; set; } = new();
}
///
/// Metadata about the search execution.
///
public class SearchMetadata
{
///
/// The normalized/parsed query string.
///
public string ParsedQuery { get; set; } = string.Empty;
///
/// Non-fatal warnings during parsing.
///
public List Warnings { get; set; } = new();
///
/// Query execution time in milliseconds.
///
public double QueryTimeMs { get; set; }
}
///
/// Result of query validation.
///
public class SearchValidationResult
{
///
/// Whether the query is valid.
///
public bool IsValid { get; set; }
///
/// Validation errors (fatal).
///
public List Errors { get; set; } = new();
///
/// Validation warnings (non-fatal).
///
public List Warnings { get; set; } = new();
}