Howto - Search for Items
This article describes how to search for items.
Content
Search criteria
For more information about the search criteria see the API specification.
Search by labels
If an item has labels attached, you can filter by these labels.
The general syntax for the request looks like this:
Syntax:
{
"labels": {
"namespace.labelName": "labelValue"
}
}
Example Search TradeItems Payload:
{
"labels": {
"test.someLabel": "someValue"
}
}
Response:
{
"hits": [
{
"supplier": "XXXXXXXXXXXXX",
"supplierItemId": "XXXXXXXXXXXXXX-XXX",
"recipient": "XXXXXXXXXXXXX",
"domain": "XXXXXXXXXXXXX",
"labels": [
{
"namespace": "test",
"labels": [
{
"name": "someLabel",
"value": "someValue"
},
{
"name": "someMoreLabel",
"value": "someMoreValue"
}
]
}
],
"enricher": null,
"digest": [],
"_links": {
"self": "v2/tradeitems/XXXXXXXXXXXXX/XXXXXXXXXXXXXX-XXX?recipient=XXXXXXXXXXXXX"
}
}
],
"total": 1,
"maybeMore": false
}
You can also use wildcards to indicate that the value should begin or end with a desired value.
To only see items where the label ends with an expected value, you can use the following syntax:
Syntax:
{
"labels": {
"namespace.labelName": "*endWithThisValue"
}
}
Example Search TradeItems Payload:
{
"labels": {
"test.someLabel": "*Value"
}
}
Response:
{
"hits": [
{
"supplier": "XXXXXXXXXXXXX",
"supplierItemId": "XXXXXXXXXXXXXX-XXX",
"recipient": "XXXXXXXXXXXXX",
"domain": "XXXXXXXXXXXXX",
"labels": [
{
"namespace": "test",
"labels": [
{
"name": "someLabel",
"value": "someValue"
},
{
"name": "someMoreLabel",
"value": "someMoreValue"
}
]
}
],
"enricher": null,
"digest": [],
"_links": {
"self": "v2/tradeitems/XXXXXXXXXXXXX/XXXXXXXXXXXXXX-XXX?recipient=XXXXXXXXXXXXX"
}
}
],
"total": 1,
"maybeMore": false
}
To only see items where the label begins with an expected value, you can use the following syntax:
Syntax:
{
"labels": {
"namespace.labelName": "BeginWithThisValue*"
}
}
Example Search TradeItems Payload:
{
"labels": {
"test.someLabel": "some*"
}
}
Response:
{
"hits": [
{
"supplier": "XXXXXXXXXXXXX",
"supplierItemId": "XXXXXXXXXXXXXX-XXX",
"recipient": "XXXXXXXXXXXXX",
"domain": "XXXXXXXXXXXXX",
"labels": [
{
"namespace": "test",
"labels": [
{
"name": "someLabel",
"value": "someValue"
},
{
"name": "someMoreLabel",
"value": "someMoreValue"
}
]
}
],
"enricher": null,
"digest": [],
"_links": {
"self": "v2/tradeitems/XXXXXXXXXXXXX/XXXXXXXXXXXXXX-XXX?recipient=XXXXXXXXXXXXX"
}
}
],
"total": 1,
"maybeMore": false
}
To only see items where there is any value for a label, you can use the following syntax:
Syntax:
{
"labels": {
"namespace.labelName": "*"
}
}
Example Search TradeItems Payload:
{
"labels": {
"test.someLabel": "*"
}
}
Response:
{
"hits": [
{
"supplier": "XXXXXXXXXXXXX",
"supplierItemId": "XXXXXXXXXXXXXX-XXX",
"recipient": "XXXXXXXXXXXXX",
"domain": "XXXXXXXXXXXXX",
"labels": [
{
"namespace": "test",
"labels": [
{
"name": "someLabel",
"value": "someValue"
},
{
"name": "someMoreLabel",
"value": "someMoreValue"
}
]
}
],
"enricher": null,
"digest": [],
"_links": {
"self": "v2/tradeitems/XXXXXXXXXXXXX/XXXXXXXXXXXXXX-XXX?recipient=XXXXXXXXXXXXX"
}
}
],
"total": 1,
"maybeMore": false
}
To only see items where a label is not set, you can use the following syntax:
Syntax:
{
"labels": {
"namespace.labelName": null
}
}
Example Search TradeItems Payload:
{
"labels": {
"test.someLabel": null
}
}
Response:
{
"hits": [
{
"supplier": "XXXXXXXXXXXXX",
"supplierItemId": "XXXXXXXXXXXXXX-XXX",
"recipient": "XXXXXXXXXXXXX",
"domain": "XXXXXXXXXXXXX",
"labels": [
{
"namespace": "test",
"labels": [
{
"name": "someMoreLabel",
"value": "someMoreValue"
}
]
}
],
"enricher": null,
"digest": [],
"_links": {
"self": "v2/tradeitems/XXXXXXXXXXXXX/XXXXXXXXXXXXXX-XXX?recipient=XXXXXXXXXXXXX"
}
}
],
"total": 1,
"maybeMore": false
}