summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--RhSolutions.Api/Controllers/SearchController.cs4
-rw-r--r--RhSolutions.Api/Migrations/20240117210635_Init.Designer.cs (renamed from RhSolutions.Api/Migrations/20230511043408_Init.Designer.cs)11
-rw-r--r--RhSolutions.Api/Migrations/20240117210635_Init.cs (renamed from RhSolutions.Api/Migrations/20230511043408_Init.cs)9
-rw-r--r--RhSolutions.Api/Migrations/RhSolutionsContextModelSnapshot.cs9
-rw-r--r--RhSolutions.Api/Models/RhsolutionsContext.cs6
5 files changed, 30 insertions, 9 deletions
diff --git a/RhSolutions.Api/Controllers/SearchController.cs b/RhSolutions.Api/Controllers/SearchController.cs
index f0402ec..162e961 100644
--- a/RhSolutions.Api/Controllers/SearchController.cs
+++ b/RhSolutions.Api/Controllers/SearchController.cs
@@ -23,9 +23,9 @@ namespace RhSolutions.Api.Controllers
public IAsyncEnumerable<Product> SearchProducts([FromQuery] string query)
{
return context.Products
- .Where(p => EF.Functions.ToTsVector(
- "russian", string.Join(' ', new[] { p.Name, string.Join(' ', p.ProductLines)}))
+ .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();
}
diff --git a/RhSolutions.Api/Migrations/20230511043408_Init.Designer.cs b/RhSolutions.Api/Migrations/20240117210635_Init.Designer.cs
index 887bd5a..8f61c8e 100644
--- a/RhSolutions.Api/Migrations/20230511043408_Init.Designer.cs
+++ b/RhSolutions.Api/Migrations/20240117210635_Init.Designer.cs
@@ -13,7 +13,7 @@ using RhSolutions.Models;
namespace RhSolutions.Api.Migrations
{
[DbContext(typeof(RhSolutionsContext))]
- [Migration("20230511043408_Init")]
+ [Migration("20240117210635_Init")]
partial class Init
{
/// <inheritdoc />
@@ -21,7 +21,7 @@ namespace RhSolutions.Api.Migrations
{
#pragma warning disable 612, 618
modelBuilder
- .HasAnnotation("ProductVersion", "7.0.5")
+ .HasAnnotation("ProductVersion", "8.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
@@ -34,7 +34,7 @@ namespace RhSolutions.Api.Migrations
b.Property<double?>("DeliveryMakeUp")
.HasColumnType("double precision");
- b.Property<List<string>>("DeprecatedSkus")
+ b.Property<string[]>("DeprecatedSkus")
.IsRequired()
.HasColumnType("text[]");
@@ -61,6 +61,11 @@ namespace RhSolutions.Api.Migrations
b.HasKey("Id");
+ b.HasIndex("Name")
+ .HasAnnotation("Npgsql:TsVectorConfig", "russian");
+
+ NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("Name"), "GIN");
+
b.ToTable("Products");
});
#pragma warning restore 612, 618
diff --git a/RhSolutions.Api/Migrations/20230511043408_Init.cs b/RhSolutions.Api/Migrations/20240117210635_Init.cs
index 7f9427f..ca7ba91 100644
--- a/RhSolutions.Api/Migrations/20230511043408_Init.cs
+++ b/RhSolutions.Api/Migrations/20240117210635_Init.cs
@@ -18,7 +18,7 @@ namespace RhSolutions.Api.Migrations
Id = table.Column<string>(type: "text", nullable: false),
Name = table.Column<string>(type: "text", nullable: false),
ProductSku = table.Column<string>(type: "text", nullable: false),
- DeprecatedSkus = table.Column<List<string>>(type: "text[]", nullable: false),
+ DeprecatedSkus = table.Column<string[]>(type: "text[]", nullable: false),
ProductLines = table.Column<List<string>>(type: "text[]", nullable: false),
IsOnWarehouse = table.Column<bool>(type: "boolean", nullable: false),
ProductMeasure = table.Column<int>(type: "integer", nullable: false),
@@ -29,6 +29,13 @@ namespace RhSolutions.Api.Migrations
{
table.PrimaryKey("PK_Products", x => x.Id);
});
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Products_Name",
+ table: "Products",
+ column: "Name")
+ .Annotation("Npgsql:IndexMethod", "GIN")
+ .Annotation("Npgsql:TsVectorConfig", "russian");
}
/// <inheritdoc />
diff --git a/RhSolutions.Api/Migrations/RhSolutionsContextModelSnapshot.cs b/RhSolutions.Api/Migrations/RhSolutionsContextModelSnapshot.cs
index 0052799..de714c1 100644
--- a/RhSolutions.Api/Migrations/RhSolutionsContextModelSnapshot.cs
+++ b/RhSolutions.Api/Migrations/RhSolutionsContextModelSnapshot.cs
@@ -18,7 +18,7 @@ namespace RhSolutions.Api.Migrations
{
#pragma warning disable 612, 618
modelBuilder
- .HasAnnotation("ProductVersion", "7.0.5")
+ .HasAnnotation("ProductVersion", "8.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
@@ -31,7 +31,7 @@ namespace RhSolutions.Api.Migrations
b.Property<double?>("DeliveryMakeUp")
.HasColumnType("double precision");
- b.Property<List<string>>("DeprecatedSkus")
+ b.Property<string[]>("DeprecatedSkus")
.IsRequired()
.HasColumnType("text[]");
@@ -58,6 +58,11 @@ namespace RhSolutions.Api.Migrations
b.HasKey("Id");
+ b.HasIndex("Name")
+ .HasAnnotation("Npgsql:TsVectorConfig", "russian");
+
+ NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("Name"), "GIN");
+
b.ToTable("Products");
});
#pragma warning restore 612, 618
diff --git a/RhSolutions.Api/Models/RhsolutionsContext.cs b/RhSolutions.Api/Models/RhsolutionsContext.cs
index be0fcb5..e21818a 100644
--- a/RhSolutions.Api/Models/RhsolutionsContext.cs
+++ b/RhSolutions.Api/Models/RhsolutionsContext.cs
@@ -18,5 +18,9 @@ public class RhSolutionsContext : DbContext
.PrimitiveCollection(e => e.DeprecatedSkus)
.ElementType()
.HasConversion(typeof(SkuConverter));
- }
+ builder.Entity<Product>()
+ .HasIndex(b => new { b.Name })
+ .HasMethod("GIN")
+ .IsTsVectorExpressionIndex("russian");
+ }
}