Business Unit Search enables merchants to search across a large number of Business Units in a Project, supporting back-office use cases.
Representations
BusinessUnitSearchRequest
query | The Business Unit Search query. |
sortArray of SearchSorting | Controls how results to your query are sorted. If not provided, the results are sorted by relevance in descending order. |
limitInt | The maximum number of search results to be returned. Default:20Minimum: 1Maximum: 100 |
offsetInt | The number of search results to be skipped in the response for pagination. Default:0Minimum: 0Maximum: 9900 |
{
"query": {
"fullText": {
"field": "all",
"value": "plumbing"
}
}
}BusinessUnitPagedSearchResponse
totalInt | Total number of results matching the query. Minimum:0 |
limitInt | Number of results requested. Minimum: 1Maximum: 100 |
offsetInt | Number of elements skipped. Minimum: 0Maximum: 9900 |
resultsArray of BusinessUnitSearchResult | Search result containing the Business Units matching the search query. |
{
"results": [
{
"id": "e41337a0-ea96-4ddc-a9a4-d267976f21e0",
"relevance": 0.9264881
},
{
"id": "05cd5998-015c-4232-8943-ff8a1880bcbc",
"relevance": 0.6989829
},
{
"id": "09c3c5a2-6569-49dd-b021-af5de4cf4b02",
"relevance": 0.6989829
}
],
"limit": 100,
"offset": 0,
"total": 3
}BusinessUnitSearchResult
idString | id of the BusinessUnit matching the search query. |
relevanceFloat | How closely this customer matches the search query. |
BusinessUnitSearchIndexingStatusResponse
status | Current status of indexing the Business Unit Search. |
states | Progress of indexing. Only available when indexing is in progress. |
startedAt | Date and time (UTC) when the last indexing started. |
retryCountInt | Indicates how many times the system tried to start indexing after failed attempts. The counter is set to null after an indexing finished successfully. |
lastModifiedAt | Time when the status was last modified. |
{
"status": "Indexing",
"states": {
"indexed": 43242,
"failed": 0,
"estimatedTotal": 100000
},
"startedAt": "2023-08-15T12:56:07.89Z",
"retryCount": 2,
"lastModifiedAt": "2023-08-15T12:56:07.89Z"
}BusinessUnitIndexingProgress
indexedInt | The number of Business Units successfully indexed. |
failedInt | The number of Business Units that failed to be indexed. |
estimatedTotalInt | The estimated total number of Business Units to be indexed. |
BusinessUnitIndexingStatus
The current indexing status of Business Unit Search.
ScheduledIndexing is scheduled.
IndexingIndexing is in progress.
Ready- Indexing is complete and the Search Business Units endpoint returns up-to-date results.
FailedIndexing failed due to an internal error.
Search Business Units
view_business_units:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString | key of the Project. |
application/jsonBusinessUnitPagedSearchResponse
asapplication/jsonGet indexing status of Business Unit Search
Returns the indexing status of the Business Unit Search for a Project.
view_project_settings:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString | key of the Project. |
BusinessUnitSearchIndexingStatusResponse
asapplication/jsoncurl --get https://api.{region}.commercetools.com/{projectKey}/business-units/search/indexing-status -i \
--header "Authorization: Bearer ${BEARER_TOKEN}"Check if Business Unit Search index exists
200 OK if an index exists; otherwise, returns a 409 Conflict.view_business_units:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString | key of the Project. |
curl --head https://api.{region}.commercetools.com/{projectKey}/business-units/search -i \
--header "Authorization: Bearer ${BEARER_TOKEN}"Searchable Business Unit fields
Number and date fields
| Standard field | Data type | Query for |
|---|---|---|
createdAt | dateTime | Business Units created at a certain date and time. |
lastModifiedAt | dateTime | Business Units last modified at any of its fields at a certain date and time. |
version | long | Business Units with a certain version of the resource. |
Example:
Find Business Units created in December 2023:
{
"query": {
"range": {
"field": "createdAt",
"gte": "2023-12-01T00:00:00.000Z",
"lt": "2024-01-01T00:00:00.000Z"
}
}
}
Text fields
| Standard field | Query for |
|---|---|
addresses.all | Business Units with a certain string in the combination of all Address fields. |
addresses.city | Business Units with a certain string in the city field of all the Business Unit's addresses. |
addresses.company | Business Units with a certain string in the company field of all the Business Unit's addresses. |
addresses.country | Business Units with a certain string in the country field of all the Business Unit's addresses. |
addresses.firstName | Business Units with a certain string in the firstName field of all the Business Unit's addresses. |
addresses.lastName | Business Units with a certain string in the lastName field of all the Business Unit's addresses. |
addresses.mobile | Business Units with a certain string in the mobile field of all the Business Unit's addresses. |
addresses.phone | Business Units with a certain string in the phone field of all the Business Unit's addresses. |
addresses.postalCode | Business Units with a certain string in the postalCode field of all the Business Unit's addresses. |
addresses.streetName | Business Units with a certain string in the streetName field of all the Business Unit's addresses. |
addresses.streetNumber | Business Units with a certain string in the streetNumber field of all the Business Unit's addresses. |
all | Business Units with a certain string in any of the Business Unit's fields. Does not support wildcard expressions. |
contactEmail | Business Units with a certain contact email. |
key | Business Units with a certain key. |
topLevelUnitKey | Business Units with a certain top level unit key. |
parentUnitKey | Business Units with a certain parent unit key. |
name | Business Units with a certain name. |
Examples:
Find Business Units with the name containing Plumbing (case insensitive):
{
"query": {
"fullText": {
"field": "name",
"value": "plumbing"
}
}
}
name, but also in contactEmail addresses like email@example.com.{
"query": {
"fullText": {
"field": "all",
"value": "example"
}
}
}
Keyword fields
| Standard field | Query for |
|---|---|
unitType | a Business Unit with a specific unitType. |
status | a Business Unit with a specific status. |
stores.key | a Business Unit of a specific Store identified by its key. |
inheritedStores.key | a Business Unit of a specific inherited Store identified by its key. |
storeMode | a Business Unit with a specific storeMode. |
Example:
Division{
"query": {
"exact": {
"field": "unitType",
"value": "Division"
}
}
}
Custom Fields
custom.<field-name> queries for Business Units with a Custom Field of a specific name, and the SearchFieldType determines the data type of the field.ltext SearchFieldType is not supported.accountPlan to the enum key of silver.{
"query": {
"exact": {
"field": "custom.accountPlan.key",
"value": "silver",
"fieldType": "enum"
}
}
}