Skip to content

Commit

Permalink
пофиксил баг если передают null текст
Browse files Browse the repository at this point in the history
  • Loading branch information
seaz96 committed Dec 8, 2024
1 parent 1851035 commit 8f373c3
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions API/Services/Search.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,21 @@
using API.Models;
using Core.Analyzer;
using Microsoft.EntityFrameworkCore;
using Microsoft.OpenApi.Services;

namespace API.Services;

public class Search(DataContext context) : ISearch
{
//todo(azanov.n): мне кажется с такими запросами я превращаюсь в trainee
//todo(azanov.n): нужно научиться обрабатывать поиск с фильтрами и null text
public async Task<List<SearchEntity>> SearchAsync(SearchQuery query)
{
if (query.Text is null)
{
return await SearchAllAsync(query).ConfigureAwait(false);
}

var words = query.Text.TokenizeText().Filter().Stem().ToArray();

var dbWords = context.Words.Where(w => words.Contains(w.Content)).Select(w => w.Id);
Expand Down

0 comments on commit 8f373c3

Please sign in to comment.