using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using RhSolutions.Models; namespace RhSolutions.Api.Controllers { [Route("api/[controller]")] public class SearchController : ControllerBase { private RhSolutionsContext context; public SearchController(RhSolutionsContext context) { this.context = context; } /// /// Поиск артикула в базе данных через предварительную мультиклассовую классификацию с применением ML-модели артикулов /// /// Запрос в свободной форме /// [HttpGet] public IAsyncEnumerable SearchProducts([FromQuery] string query) { return context.Products .Where(p => EF.Functions.ToTsVector("russian", p.Name) .Matches(EF.Functions.WebSearchToTsQuery("russian", query))) .Where(p => p.ProductLines.Contains("RAUTITAN")) .OrderByDescending(p => p.IsOnWarehouse) .AsAsyncEnumerable(); } } }