Rule query
editRule query
editThis functionality is in technical preview and may be changed or removed in a future release. Elastic will work to fix any issues, but features in technical preview are not subject to the support SLA of official GA features.
Applies query rules to the query before returning results. This feature is used to promote documents in the manner of a Pinned Query based on matching defined rules. If no matching query rules are defined, the "organic" matches for the query are returned. All matching rules are applied in the order in which they appear in the query ruleset.
To use the rule query, you first need a defined set of query rules. Use the query rules management APIs to create and manage query rules. For more information and examples see Searching with query rules.
Example request
editGET /_search { "query": { "rule_query": { "match_criteria": { "user_query": "pugs" }, "ruleset_id": "my-ruleset", "organic": { "match": { "description": "puggles" } } } } }
Top-level parameters for rule_query
edit-
ruleset_id
- (Required, string) A unique query ruleset ID with query-based rules to match and apply as applicable.
-
match_criteria
-
(Required, object) Defines the match criteria to apply to rules in the given query ruleset.
Match criteria should match the keys defined in the
criteria.metadata
field of the rule. -
organic
- (Required, object) Any choice of query used to return results, that may be modified by matching query rules. If no query rules are matched and applied, this query will be executed with no modification.