Query Logic

Combine conditions with AND/OR logic using groupKey and groupType. Build complex boolean expressions for advanced filtering with faceted search patterns.

Syntax

Parameters

ParameterTypeRequiredDescription
groupKeystring No Groups conditions together. Same groupKey = same logical group.
groupType'and' | 'or' No Logic within the group. Default: 'and' across groups.
mode (2nd arg)'add' | 'set' No 'add' (default) adds to existing, 'set' replaces existing for attribute

Return Type

Returns void. Query state is updated. Use current() to inspect, clear() to reset.

Usage Notes

  • Default: different attributes use AND, same attribute uses OR
  • Use groupKey + groupType: 'or' for explicit OR across different attributes
  • Different groupKeys are ANDed together at the top level
  • Use mode: 'set' for single-select dropdowns (replaces previous)
  • Use mode: 'add' for multi-select checkboxes (accumulates)
  • removeCondition() removes specific conditions by attribute/value
  • clear() removes all conditions

Related Methods

  • catalog.query.current() - Get current query structure
  • catalog.query.isEmpty() - Check if any conditions exist
  • catalog.query.clear() - Remove all conditions
  • catalog.query.removeCondition() - Remove specific condition

Examples

Default AND Logic

Multiple conditions on different attributes use AND by default.

OR Logic with Same Attribute

Multiple values for same attribute create OR logic by default.

Explicit OR Group

Use groupKey and groupType for explicit OR logic across different attributes.

Multiple OR Groups (AND between groups)

Combine multiple OR groups with AND logic between them.

Faceted Search Pattern

Build a typical e-commerce filter with multiple facets.

mode: set vs mode: add

Control whether new conditions replace or add to existing ones.

Remove Specific Condition

Remove a specific condition while keeping others.

Query State Inspection

Check current query state and reset.

Conditional UI based on Query State

Use isEmpty() and has() to drive UI decisions.