Search API
The API supports a searching mechanism to easily find back the items you are looking for. The search API has the ability to use search text, facets, filtering and paging. Navigate through the menu to find related documentation.
Example:
{
"filter": "colour.eq.red",
"searchText": "curtain",
"page": 1,
"pageSize": 20,
"sortAttribute": "name",
"sortDirection": "ASC",
"facets": [
{
"attribute": "type"
},
{
"attribute": "colour"
}
]
}
Note that when searching for items, it could be that not all properties are returned in the response. The API will only return those that are available in the search engine and are configured to be returned.
Example
ODS-Item-Version: 2.0
Item versioning
The portal supports item versioning. Based on the value for the version, the JSON result is returned differently.
By default, the portal supports 2 versions, the current one and the previous one.
To define the version, add a header parameter ODS-Item-Version.
The version should be of format {Major.Minor}
.
The current version is: 2.0
The previous version is: 1.0
Note: This header variable is required and it is recommended to use the latest available version of the API.
Search query examples
Some examples of search queries:
Search all related render assets for a product: assetSource.eq.Render Pipeline/salesId.eq.{productId}
Search all related sofa and curtain renditions for a product: assetSource.eq.Render Pipeline/salesId.eq.{productid}/assetType.eq.any(Sofa,Curtain)
Search all one seated sofa renditions for a product that have a white wall colour: assetSource.eq.Render Pipeline/salesId.eq.{productid}/assetType.eq.Sofa/sofaSize.eq.One Seat/wallColour.eq.White
Selected Product (by the Bru product name, brings back all assets for the product or collection with the selected name contained): E.g., https://api.twinbru.com/ods/item-read/v1/api/Search/Asset?SearchText=thor
Selected Product and Colour (by the Bru colour code): E.g., https://api.twinbru.com/ods/item-read/v1/api/Search/Asset?filter=salesId.eq.64331
Search for a specific asset type (e.g. Ball, Bed, Chair, Curtain, Pouf, RoomShot, Sofa, Twist, Wrinkeled, FlatShot, CloseUp): E.g., https://api.twinbru.com/ods/item-read/v1/api/Search/Asset?filter=assetType.eq.roomshot
Difference between https://api.twinbru.com/ods/item-read/v1/api/Search/Asset?filter=salesId.eq.68306 and https://api.twinrbu.com/ods/item-read/v1/api/Search/Asset?filter=assetSource.eq.Render_Pipeline/salesid.eq.73994 lies in the one just retrieving all kinds of assets (both regular photography and digital renders) and the other one retrieving only digital render assets.
Both https://api.twinbru.com/ods/item-read/v1/api/Search/Asset?filter=assetType.eq.sofa and
https://api.twinbru.com/ods/item-read/v1/api/Search/Asset?filter=assetType.eq.sofa/sofastyle.eq.modern work but note that there are no metadata available for sofastyle yet.Both https:/api.twinbru.com/ods/item-read/v1/api/Search/Asset?filter=assetType.eq.Roomshot/collection.eq.457 and
https://api.twinbru.com/ods/item-read/v1/api/Search/Asset?filter=assetType.eq.Roomshot/collection.eq.457/roomtype.eq.traditional work but note that there are no metadata available for roomtype yet.
Retrieving assets
The API endpoints that are available in the current version are very generic. The “item type” parameter indicates what kind of items that need to be queried on. In our case we want to fetch assets so the item type should be “asset”. So for {type} you need to use the value “asset” when you want to fetch assets.
The {id} parameter depends on the {type}. To fetch assets the {id} value should be an asset id and not a product/colour id. In our system an asset id looks like this “69499550-84a8-4d2f-9b40-a67c00e8fcf3”. The {id} is only needed if you want to retrieve the data for 1 single asset. The value for {id} can be found in the attribute “assetId” in the JSON response of the Search API.
As URL this looks as follows:
https://api.twinbru.com/ods/item-read/v1/api/Search/Asset
https://api.twinbru.com/ods/item-read/v1/api/Items/Asset/69499550-84a8-4d2f-9b40-a67c00e8fcf3
This should already give results in the items API.
When using the Item Search API, a couple of parameters can be added:
Filter
Page
PageSize
SortAttribute
SortDirection
…
To filter on assets, the API query language must be used. Filtering supports different operations (equal, not equal, …) and multiple filters can be combined. Basically, every attribute that is returned in the search result, can be used in the search filter. To fetch a certain asset type, U can use the following filter: assetType.eq.RoomShot
The filter “assetType.eq.Roomshot” can be added in the URL for a GET request and in the body for a POST request. A search can be done with a GET request or a POST request. When using the GET request, all parameters should be provided in the URL as a query string. When using the POST request, all parameters should be defined in the body as JSON text.
The following example assumes that a GET request is used: https://api.twinbru.com/ods/item-read/v1/api/Search/Asset?filter=assetType.eq.roomshot.
The URL used for testing the POST Search Item API is: https://api.twinbru.com/ods/item-read/v1/api/search/asset
An asset in the data store contains limited product data such as a product ID. This attribute is called “salesId” in the data store. Retrieving assets for a specific article can be done via the following URL: https://api.twinbru.com/ods/item-read/v1/api/Search/Asset?filter=salesId.eq.{id}
The search filter will split up your search term and try to find matches based on parts of the word or the complete word. This means that searching for “thor” should return “author”. The current version of our searching mechanism will only go through textual values from the field “assetName”. In most cases, the asset name contains the colour name so searching on that should work fine. Every field that is returned by the Search API can be used for filtering.
More product properties that are enabled for filtering:
Brand
Collection
Design
SalesId
When searching for render assets, the following example properties are enabled for filtering:
When sofa render
SofaStyle
Examples: Cabriole, Camelback, Modern, Traditional, …
SofaSize
Examples: Chaise longue, one seat, sectional, two seat, three seat
When curtain
CurtainLength
Examples: Break, Puddle, Short
General render
RenderScene
RenderView
LightSetting
WallColour
FloorType
RoomType
Examples: Modern, Traditional, Contemporary
The easiest way to get all available values from the API is by faceting on them with a page size of 0.
Send a POST request to the Search API with following JSON in the request body:
{
"pageSize": 0,
"facets": [
{
"attribute": "roomType"
}
]
}
This will return all possible values with their count (example result below).
{
"results": [],
"facets": [
{
"name": "roomType",
"displayName": "roomType",
"totalValueCount": 4,
"values": [
{
"key": "residential",
"displayName": "Residential",
"value": "Residential",
"count": 7,
"countText": "7",
"sortKey": "Residential"
},
{
"key": "livingroom",
"displayName": "Livingroom",
"value": "Livingroom",
"count": 1,
"countText": "1",
"sortKey": "Livingroom"
},
{
"key": "modern",
"displayName": "Modern",
"value": "Modern",
"count": 1,
"countText": "1",
"sortKey": "Modern"
},
{
"key": "outdoor",
"displayName": "Outdoor",
"value": "Outdoor",
"count": 1,
"countText": "1",
"sortKey": "Outdoor"
}
]
}
],
"page": 1,
"totalPageCount": 0,
"totalItemCount": 85048
}