using OpenSearch.Client; using System; using System.Collections.Generic; using System.Text; namespace Store.Modules.CloudProduct.Dtos { /// /// 商品搜索模型:Id 为主键,Title 用于分词搜索 /// public class ProductSearchInfo { [Number(NumberType.Byte, Name = "platform")] public byte Platform { get; set; } [Number(NumberType.Long, Name = "id")] public long Id { get; set; } [Text(Name = "title", Analyzer = "ik_max_word", SearchAnalyzer = "ik_smart")] public string Title { get; set; } = string.Empty; [Text(Name = "thumbUrl")] public string? ThumbUrl { get; set; } = string.Empty; /// 一级类目ID [Number(NumberType.Integer, Name = "cat_id_1")] public int? CatId1 { get; set; } /// 二级类目ID [Number(NumberType.Integer, Name = "cat_id_2")] public int? CatId2 { get; set; } /// 三级类目ID [Number(NumberType.Integer, Name = "cat_id_3")] public int? CatId3 { get; set; } /// 四级类目ID [Number(NumberType.Integer, Name = "cat_id_4")] public int? CatId4 { get; set; } /// 最低价快照,用于价格区间过滤和按价格排序 [Number(NumberType.Long, Name = "min_price")] public long? MinPrice { get; set; } /// 销量,用于按销量排序 [Number(NumberType.Integer, Name = "sold_quantity")] public int SoldQuantity { get; set; } public override string ToString() => $"[Id={Id}] Title={Title} Cat=({CatId1},{CatId2},{CatId3},{CatId4}) Price={MinPrice} Sold={SoldQuantity}"; } /// /// 搜索排序方式 /// public enum GoodsSearchSortBy { Relevance = 0, // 相关性(默认) PriceAsc = 1, // 价格从低到高 PriceDesc = 2, // 价格从高到低 SoldDesc = 3, // 销量从高到低 } }