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: docs/search-and-query/search-and-query.md
+23-11Lines changed: 23 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -567,11 +567,7 @@ Since we don't have context of the logged-in user when using the API, these func
567
567
568
568
### Contextual query rules
569
569
570
-
:::info Closed beta feature
571
-
This capability is currently in closed beta, and is not yet generally available.
572
-
If you would like to join the beta, please reach out to us.
573
-
:::
574
-
To implement specific and/or complex queries, you can add the context of the triggering user to a query rule, allowing you to access that user's entity and/or owning teams.
570
+
To implement specific and/or complex queries, you can add the context of the triggering user to a query rule, allowing you to access that user's properties and/or owning teams.
575
571
You can mix contextual query rules freely with other rules as part of your queries.
576
572
This can be used in either the `property` or `value` key in a query rule:
577
573
@@ -610,37 +606,53 @@ This can be used in either the `property` or `value` key in a query rule:
610
606
|`userTeams`| The entities of the owning teams of the user triggering the query |
611
607
612
608
#### Usage examples
613
-
609
+
The following rule will result in the entities owned by any one of the user's teams:
614
610
```json showLineNumbers
615
611
[
616
612
...other rules
617
-
{ // filter entities with the same department as the user
618
-
"property": "department",
613
+
{
614
+
"property": "$team",
619
615
"operator": "containsAny",
616
+
"value": {
617
+
"context": "userTeams",
618
+
"property": "$identifier"
619
+
}
620
+
}
621
+
]
622
+
```
623
+
The following rule will result in entities with the same department as the user's:
624
+
```json showLineNumbers
625
+
[
626
+
...other rules
627
+
{
628
+
"property": "department",
629
+
"operator": "=",
620
630
"value": {
621
631
"context": "user",
622
632
"property": "department"
623
633
}
624
634
}
625
635
]
626
636
```
637
+
The following rule asserts that only users with `manager` role will get the resulting entities:
627
638
```json showLineNumbers
628
639
[
629
640
...other rules
630
-
{ // only users with `manager` role will get the entities
641
+
{
631
642
"property": {
632
643
"context": "user",
633
-
"property": "role"
644
+
"property": "port_role"
634
645
},
635
646
"operator": "=",
636
647
"value": "manager"
637
648
}
638
649
]
639
650
```
651
+
The following rule asserts that only users in the user's team/s will get the resulting entities:
640
652
```json showLineNumbers
641
653
[
642
654
...other rules
643
-
{ // only users in these team will get the entities
0 commit comments