You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/pages/graphql/schema/live-search/queries/product-search.md
+41-15Lines changed: 41 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -386,7 +386,18 @@ filter:[
386
386
387
387
##### Error handling for categoryPath
388
388
389
-
When an empty or invalid `categoryPath` is detected with position sorting, the following warning is returned:
389
+
When sorting by category `position` with an empty or invalid `categoryPath`, the Search Service gracefully handles the request to prevent `FAILED_PRECONDITION` errors. This scenario commonly occurs when attempting to sort by position at the root category level, where category paths are not standardized across store views.
390
+
391
+
**Behavior when empty or invalid categoryPath is detected with position sorting:**
392
+
393
+
- Category position sort is ignored
394
+
- System falls back to relevance-based sorting
395
+
- Products are returned successfully
396
+
- A structured GraphQL warning is included in the response
397
+
398
+
**Warning message:**
399
+
400
+
The following warning is returned in the `errors` array alongside the product data:
390
401
391
402
```json
392
403
{
@@ -404,26 +415,41 @@ When an empty or invalid `categoryPath` is detected with position sorting, the f
404
415
}
405
416
```
406
417
407
-
Despite the warning, the query returns product data successfully in the `data` object, sorted by relevance.
418
+
<InlineAlertvariant="info"slots="text"/>
419
+
420
+
Despite the warning, the query executes successfully and returns product data in the `data` object, sorted by relevance instead of position.
408
421
409
-
**Example**
422
+
**Example query that triggers the warning:**
410
423
411
424
```graphql
412
-
filter: [
413
-
{
414
-
attribute: "categoryPath",
415
-
eq: null
416
-
}
417
-
]
418
-
sort: [
419
-
{
420
-
attribute: "position",
421
-
direction: "ASC"
425
+
{
426
+
productSearch(
427
+
phrase: "pants"
428
+
page_size: 8
429
+
filter: [
430
+
{
431
+
attribute: "categoryPath",
432
+
eq: null
433
+
}
434
+
]
435
+
sort: [
436
+
{
437
+
attribute: "position",
438
+
direction: ASC
439
+
}
440
+
]
441
+
) {
442
+
items {
443
+
productView {
444
+
name
445
+
sku
446
+
}
447
+
}
422
448
}
423
-
]
449
+
}
424
450
```
425
451
426
-
This configuration triggers the warning and applies relevance sorting instead of position sorting.
452
+
In this example, attempting to sort by `position` with a null `categoryPath`triggers the warning. The system returns products sorted by relevance with the warning message included in the response.
0 commit comments