Create or update a query rule within a query ruleset.
IMPORTANT: Due to limitations within pinned queries, you can only pin documents using ids or docs, but cannot use both in single rule. It is advised to use one or the other in query rulesets, to avoid errors. Additionally, pinned queries have a maximum limit of 100 pinned hits. If multiple matching rules pin more than 100 documents, only the first 100 documents are pinned in the order they are specified in the ruleset.
manage_search_query_rulesThe unique identifier of the query ruleset containing the rule to be created or updated.
The unique identifier of the query rule within the specified ruleset to be created or updated.
The type of rule.
Values are pinned or exclude.
The actions to take when the rule is matched. The format of this action depends on the rule type.
POST _query_rules/my-ruleset/_test
{
"match_criteria": {
"query_string": "puggles"
}
}
resp = client.query_rules.test(
ruleset_id="my-ruleset",
match_criteria={
"query_string": "puggles"
},
)
const response = await client.queryRules.test({
ruleset_id: "my-ruleset",
match_criteria: {
query_string: "puggles",
},
});
response = client.query_rules.test(
ruleset_id: "my-ruleset",
body: {
"match_criteria": {
"query_string": "puggles"
}
}
)
$resp = $client->queryRules()->test([
"ruleset_id" => "my-ruleset",
"body" => [
"match_criteria" => [
"query_string" => "puggles",
],
],
]);
curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d '{"match_criteria":{"query_string":"puggles"}}' "$ELASTICSEARCH_URL/_query_rules/my-ruleset/_test"
{
"match_criteria": {
"query_string": "puggles"
}
}