-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProduct.cs
More file actions
111 lines (86 loc) · 3.27 KB
/
Product.cs
File metadata and controls
111 lines (86 loc) · 3.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
using Weaviate.Client.Managed.Attributes;
using Weaviate.Client.Models;
namespace Example;
/// <summary>
/// Represents a product in an e-commerce catalog.
/// </summary>
[WeaviateCollection(Name = "Product", Description = "Product catalog for e-commerce")]
public record Product
{
[WeaviateUUID]
public Guid UUID { get; set; }
[Property(Description = "Product name")]
public string Name { get; set; } = "";
[Property(Description = "Product description")]
[Index(Searchable = true)]
[Tokenization(PropertyTokenization.Word)]
public string Description { get; set; } = "";
[Property(Description = "Product category")]
[Index(Filterable = true)]
public string Category { get; set; } = "";
[Property(DataType.Number, Description = "Product price in USD")]
[Index(Filterable = true)]
public decimal Price { get; set; }
[Property(Description = "Brand name")]
[Index(Filterable = true)]
public string Brand { get; set; } = "";
[Property(DataType.Number, Description = "Average rating (1-5)")]
[Index(Filterable = true)]
public double Rating { get; set; }
[Property(DataType.Int, Description = "Stock quantity")]
public int Stock { get; set; }
[Property(Description = "Product specifications")]
[NestedType(typeof(ProductSpecifications))]
public ProductSpecifications? Specs { get; set; }
// Optional: vector for semantic search (can be omitted if no vectorizer)
// [Vector<Vectorizer.Text2VecCohere>(Name = "description")]
// public float[]? DescriptionVector { get; set; }
// Metadata properties
[MetadataProperty]
public double? Score { get; set; }
[MetadataProperty]
public double? Distance { get; set; }
}
/// <summary>
/// Product specifications as a nested object.
/// </summary>
public record ProductSpecifications
{
[Property(Description = "Product color")]
public string? Color { get; set; }
[Property(Description = "Product size")]
public string? Size { get; set; }
[Property(DataType.Number, Description = "Weight in pounds")]
public double? Weight { get; set; }
[Property(Description = "Material")]
public string? Material { get; set; }
}
/// <summary>
/// Represents a customer review for a product, demonstrating cross-collection references.
/// </summary>
[WeaviateCollection(Name = "ProductReview", Description = "Customer reviews for products")]
public record ProductReview
{
[WeaviateUUID]
public Guid UUID { get; set; }
[Property(Description = "Review title")]
public string Title { get; set; } = "";
[Property(Description = "Review content")]
[Index(Searchable = true)]
[Tokenization(PropertyTokenization.Word)]
public string Content { get; set; } = "";
[Property(DataType.Number, Description = "Rating (1-5)")]
[Index(Filterable = true)]
public double Rating { get; set; }
[Property(Description = "Reviewer name")]
public string ReviewerName { get; set; } = "";
[Property(Description = "Review date")]
public DateTime ReviewDate { get; set; }
// Reference to the Product being reviewed
// Demonstrates cross-collection relationships
[Reference]
public Product? Product { get; set; }
// Metadata properties
[MetadataProperty]
public double? Score { get; set; }
}