Update by Query
PATCHOverview
Section titled “Overview”This endpoint allows you to perform bulk updates on objects that match a specific set of criteria. It is an asynchronous operation: the API call initiates a background job, and you must poll a status URL to check its progress.
Request structure
Section titled “Request structure”The request body consists of two main parts: a search object to define the update criteria and an update object to specify the changes.
Request body structure
Section titled “Request body structure”| Parameter | Type | Required | Description |
|---|---|---|---|
search | Object | ✓ | An object containing rules to select which items will be updated. |
update | Object | ✓ | An object specifying the field changes to apply to all matching items. |
search Object Parameters
Section titled “search Object Parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
types | Array | ✓ | An array of strings specifying the object types to include in the search, for example ["item"]. |
partial | Object | ✓ | An object containing the fields to match. Currently only fields is supported within partial. |
update Object Parameters
Section titled “update Object Parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
fields | Object | ✓ | An object specifying the fields to update and their new values. |
How to Initiate an Update Job
Section titled “How to Initiate an Update Job”The process involves two steps. First, you send a PATCH request with your search and update rules to start the background job.
Authentication is required for all requests. The code demonstrates how to construct the necessary headers, including Date and Authorization. The Authorization header requires a dynamically generated HMAC signature.
The search criteria work on a partial match principle for array values and are case-sensitive. For example, a search for color: 'olive' matches a product with color: ['olive', 'red']. A search for category: 'jeans' will not match a product with category: 'Jeans'.
Important: The update operation is a replacement for the specified fields, not an incremental change.
Check job status
Section titled “Check job status”After a successful PATCH request, the API responds with a status_url. You must then make a GET request to this URL to check the status of the background job. You may need to poll this endpoint until the status field changes from "in_progress" to "complete".
Status Check Request
GET https://live.luigisbox.com/v1/update_by_query?job_id=12345The response shows the current status of your bulk update operation.
Job completion response
Section titled “Job completion response”Once the job is finished, the GET request to the status URL returns a summary of the results, including the number of successful updates and any failures.
Response fields
Section titled “Response fields”| Field | Type | Description |
|---|---|---|
tracker_id | String | Your tracker identifier. |
status | String | Job status: in_progress, complete, or failed. |
updates_count | Integer | Number of objects successfully updated. |
failures_count | Integer | Number of objects that failed to update. |
failures | Object | Details about any failures, empty if none. |
Error handling
Section titled “Error handling”| HTTP Status | Description |
|---|---|
| 400 Bad Request | The request structure is invalid, JSON is malformed, or some objects failed validation. Check the response body for details. |
| 403 Forbidden | The request is not allowed for your site in Luigi’s Box. |
| 405 Method Not Allowed | The request method is not supported for the specified resource. |
| 413 Payload Too Large | The request exceeds 5 MB, or 10 MB if compressed. Reduce batch size or enable compression. |
Related endpoints
Section titled “Related endpoints”- Content Update creates or replaces objects.
- Partial Content Update updates specific fields only.
- Content Removal deletes objects from the index.
Was this page helpful?
Thanks.