attributeMetadata query
The attributeMetadata query returns a list of product attribute codes that can be used for sorting or filtering in a productSearch query. The query response can include the attribute name, display label, and a Boolean value that indicates if the attribute has a numeric value that can be used for numeric operations, such as range filters or sorting.
Syntax
attributeMetadata: AttributeMetadataResponse!
Endpoints
data-src=../../../../includes/graphql/endpoints.md
Required headers
You must specify the following HTTP headers to run this query.
data-src=../../../../includes/graphql/live-search-headers.md
Example usage
The following query returns details about all product attributes that can be used to define the sorting order or as a filter in a productSearch query.
Request:
{
attributeMetadata{
sortable {
attribute
label
numeric
}
filterableInSearch {
attribute
label
numeric
}
}
}
Response:
{
"extensions": {
"request-id": "5Kd6pzYc02PlHIbbmNDTff3VaXF0EnYf"
},
"data": {
"attributeMetadata": {
"sortable": [
{
"attribute": "name",
"label": "Product Name",
"numeric": false
},
{
"attribute": "price",
"label": "Price",
"numeric": true
},
{
"attribute": "position",
"label": "position",
"numeric": true
}
],
"filterableInSearch": [
{
"attribute": "categoryIds",
"label": "categoryIds",
"numeric": false
},
{
"attribute": "collar",
"label": "Collar",
"numeric": false
},
{
"attribute": "visibility",
"label": "visibility",
"numeric": false
},
{
"attribute": "activity",
"label": "Activity",
"numeric": false
},
{
"attribute": "gender",
"label": "Gender",
"numeric": false
},
{
"attribute": "size",
"label": "Size",
"numeric": false
},
{
"attribute": "price",
"label": "price",
"numeric": true
},
{
"attribute": "sleeve",
"label": "Sleeve",
"numeric": false
},
{
"attribute": "eco_collection",
"label": "Eco Collection",
"numeric": false
},
{
"attribute": "categories",
"label": "categories",
"numeric": false
},
{
"attribute": "climate",
"label": "Climate",
"numeric": false
},
{
"attribute": "sku",
"label": "sku",
"numeric": false
}
]
}
}
}
Output fields
The AttributeMetadataResponse return object can contain the following fields:
filterableInSearchproductSearch querysortableproductSearch queryFilterableInSearchAttribute data type
The FilterableInSearchAttribute data type can contain the following fields:
attributelabelnumericSortableAttribute data type
The SortableAttribute data type can contain the following fields:
attributelabelnumeric