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
To create a new query ruleset and the first query rule:
44
+
45
+
1. Click **Query Rules** in the navigation menu under **Relevance**
46
+
2. Click **Create ruleset**:
47
+
- Enter a name for the ruleset
48
+
- Click **Create ruleset** to confirm
49
+
50
+
The rule creation section opens:
51
+
52
+
3. Select rule type:
53
+
- **Pin**: Pin selected documents to the top of the search results.
54
+
- **Exclude**: Exclude selected documents from the results.
55
+
4. Select one or more documents for the rule to apply to.
56
+
5. Select rule type:
57
+
-**Always**: Apply the rule to all queries
58
+
-**Custom**: Define conditions when the rule is applied.
59
+
60
+
For a full list of options see [Searching with query rules](elasticsearch://reference/elasticsearch/rest-apis/searching-with-query-rules.md#query-rule-criteria)
61
+
6. Click **Create rule**
62
+
7. Click **Save** in the top right corner of the ruleset section
1. Click **Query Rules** in the navigation menu under **Relevance**
75
+
2. Click **Delete** or select it from the action menu (**...**)
76
+
3. Select if the ruleset is safe to delete.
77
+
4. Click **Delete ruleset**
78
+
79
+
### Modify rules
80
+
81
+
:::{important}
82
+
After modifying any rules, make sure to save the changes in the ruleset section.
83
+
Unsaved rules will not be applied even if they appear in the UI.
84
+
:::
85
+
86
+
#### Edit a rule
87
+
1. Click **Query Rules** in the navigation menu under **Relevance**
88
+
2. Select a ruleset
89
+
3. Select **Edit** from the action menu (**...**)
90
+
4. Apply changes to the rule
91
+
5. Confirm you modification by selectin **Update rule**
92
+
6. Click **Save** in the top right corner of the ruleset section
93
+
94
+
#### Delete a rule
95
+
1. Click **Query Rules** in the navigation menu under **Relevance**
96
+
2. Select a ruleset
97
+
3. Select **Delete rule** from the action menu (**...**)
98
+
4. Click **Delete rule**
99
+
6. Click **Save** in the top right corner of the ruleset section
100
+
101
+
### Re-order rules
102
+
103
+
1. Click **Query Rules** in the navigation menu under **Relevance**
104
+
2. Select a ruleset
105
+
3. Drag a rule using the handle icon (≡) on the left.
106
+
4. Drop it in the new position.
107
+
5. Click **Save** in the top right corner of the ruleset section
108
+
109
+
### Test and validate a ruleset
110
+
111
+
1. Click **Query Rules** in the navigation menu under **Relevance**
112
+
2. Select a ruleset
113
+
3. Click **Test in Console**.
114
+
115
+
A console window opens containing a sample query using the [rule retriever](elasticsearch://reference/elasticsearch/rest-apis/retrievers/rule-retriever.md).
116
+
117
+
```console
118
+
GET books/_search
119
+
{
120
+
"retriever": {
121
+
"rule": {
122
+
// Update your criteria to test different results
123
+
"match_criteria": {
124
+
"query_string": "Stephenson"
125
+
},
126
+
"ruleset_ids": [
127
+
"first-ruleset"
128
+
],
129
+
"retriever": {
130
+
"standard": {
131
+
"query": {
132
+
"match_all": {} <1>
133
+
}
134
+
}
135
+
}
136
+
}
137
+
}
138
+
}
139
+
```
140
+
1. Modify the search query if needed.
141
+
142
+
6. Run the query.
143
+
7. Review results and confirm whether the rule actions were applied as expected.
0 commit comments