Attribute Fields
Attribute Fields
Product attributes in Makaira are stored as nested arrays, organized by data type. This structure enables flexible filtering and faceted search.
Attribute Types
| Field | Type | Description |
|---|---|---|
attributeStr | nested array | String/text attributes |
attributeInt | nested array | Integer attributes |
attributeFloat | nested array | Decimal/float attributes |
attributes | nested array | Aggregated attributes (generated) |
Attribute Structure
Each attribute entry contains:
| Property | Type | Description |
|---|---|---|
id | string | Unique attribute identifier |
title | string | Human-readable attribute name |
value | varies | Attribute value (type depends on array) |
Example
{
"id": "product-123",
"type": "product",
"attributeStr": [
{"id": "color", "title": "Color", "value": "Blue"},
{"id": "material", "title": "Material", "value": "Cotton"},
{"id": "brand", "title": "Brand", "value": "Nike"}
],
"attributeInt": [
{"id": "weight_g", "title": "Weight (g)", "value": 200},
{"id": "pack_size", "title": "Pack Size", "value": 1}
],
"attributeFloat": [
{"id": "rating", "title": "Rating", "value": 4.5},
{"id": "discount_percent", "title": "Discount %", "value": 15.0}
]
}Multi-Value Attributes
For attributes with multiple values, use the # separator:
{
"attributeStr": [
{"id": "color", "title": "Color", "value": "Blue#Red#Green"},
{"id": "size", "title": "Size", "value": "S#M#L#XL"}
]
}During import, these are split into individual values for filtering.
Attribute Sub-Fields
Each attribute value has these sub-fields for different query types:
| Sub-Field | Type | Purpose |
|---|---|---|
attributeStr.value.unanalyzed | keyword | Exact matching |
attributeStr.value.lowercase | keyword | Case-insensitive matching |
attributeStr.value.sorting | keyword | Alphabetical sorting |
attributeStr.value.delimiter | text | Delimiter-based matching |
attributeStr.value.unstemmed | text | Full-text without stemming |
Variant Attribute Aggregation
When using the Persistence Layer, attributes from variants are automatically aggregated to the parent product.
How It Works
- All variants with
active: trueANDonstock: trueare included - Attributes are merged and deduplicated
- Result is stored in the
attributesfield on the parent product
Example
Variant 1:
{"attributeStr": [{"id": "size", "value": "S"}, {"id": "color", "value": "Blue"}]}Variant 2:
{"attributeStr": [{"id": "size", "value": "M"}, {"id": "color", "value": "Blue"}]}Variant 3 (inactive):
{"attributeStr": [{"id": "size", "value": "L"}, {"id": "color", "value": "Red"}]}Parent Product (aggregated):
{
"attributes": [
{"id": "size", "value": ["S", "M"]},
{"id": "color", "value": ["Blue"]}
]
}Note: Variant 3's attributes are excluded because it's inactive.
Without Persistence Layer: You must manually aggregate attributes in your import data.
Using Attributes in Product Streams
Attributes can be used in stream filters with this field format:
| Field Format | Description |
|---|---|
attributeStr::ATTRIBUTE_ID | Filter on string attribute |
attributeInt::ATTRIBUTE_ID | Filter on integer attribute |
attributeFloat::ATTRIBUTE_ID | Filter on float attribute |
Example Stream Filter
{
"field": "attributeStr::color",
"type": "nested",
"operator": "eq",
"value": "Blue"
}Best Practices
-
Use correct types - Put numeric values in
attributeIntorattributeFloat, notattributeStr. -
Consistent IDs - Use the same attribute
idacross all products for proper filtering. -
Meaningful titles - The
titlefield is used in filter displays. -
Multi-values with # - Use the
#separator for multi-value attributes. -
Keep variants active - Only active and in-stock variants are aggregated to the parent.
Updated about 14 hours ago
