PHPackages                             rapidez/statamic-query-builder - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. rapidez/statamic-query-builder

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

rapidez/statamic-query-builder
==============================

Statamic Query Builder addon

2.3.0(6mo ago)01.9k↓33.3%1[2 PRs](https://github.com/rapidez/statamic-query-builder/pulls)GPL-3.0-or-laterPHPCI passing

Since Dec 18Pushed 2mo ago5 watchersCompare

[ Source](https://github.com/rapidez/statamic-query-builder)[ Packagist](https://packagist.org/packages/rapidez/statamic-query-builder)[ Docs](https://github.com/rapidez/statamic-query-builder)[ RSS](/packages/rapidez-statamic-query-builder/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (11)Versions (22)Used By (0)

Statamic Query Builder
======================

[](#statamic-query-builder)

A sophisticated visual query builder for Statamic CMS that generates Elasticsearch DSL queries for complex product filtering and search. Built specifically for e-commerce applications using the Rapidez framework.

Features
--------

[](#features)

### Visual Query Building

[](#visual-query-building)

- **Drag &amp; drop interface** - Build complex queries without writing code
- **Nested group logic** - Create groups within groups with AND/OR operators
- **Collapsible groups** - Manage complex queries with expandable sections
- **Visual condition builder** - Point-and-click interface for all query operations

### E-commerce Focused

[](#e-commerce-focused)

- **Product attribute integration** - Automatically fetches and maps product attributes
- **Stock status queries** - Built-in support for inventory filtering
- **Elasticsearch DSL generation** - Converts visual queries to optimized search syntax
- **Performance caching** - Cached query generation for better performance

### Advanced Field Types

[](#advanced-field-types)

- **Text fields** - String operations (contains, starts with, ends with, etc.)
- **Select fields** - Single and multi-select with custom options
- **Number fields** - Numeric comparisons and ranges
- **Date fields** - Advanced date filtering with relative and absolute dates
- **Stock status** - Specialized e-commerce inventory filtering

### Powerful Date Operations

[](#powerful-date-operations)

- **Relative dates** - TODAY, TOMORROW, YESTERDAY
- **Dynamic ranges** - LAST\_X\_DAYS, NEXT\_X\_DAYS with custom offsets
- **Period filters** - THIS\_WEEK, THIS\_MONTH, THIS\_YEAR
- **Manual dates** - Custom date picker for specific dates
- **Offset calculations** - Today ± X days/weeks/months/years

### Query Management

[](#query-management)

- **Query presets** - Save and load common filtering scenarios
- **Template system** - Multiple output formats (slider, listing, etc.)
- **Import/export** - Share query configurations
- **Validation** - Automatic validation and correction of imported queries

### Professional Features

[](#professional-features)

- **Unlimited nesting** - Groups within groups with no limits
- **Reorderable conditions** - Drag conditions and groups to reorder
- **Duplicate functionality** - Clone groups and conditions
- **Conflict resolution** - Smart handling of preset merging vs overriding

Installation
------------

[](#installation)

Install via Composer:

```
composer require rapidez/statamic-query-builder
```

Publish the configuration and views:

```
php artisan vendor:publish --provider="Rapidez\StatamicQueryBuilder\ServiceProvider"
```

Quick Start
-----------

[](#quick-start)

### Basic Product Query Builder

[](#basic-product-query-builder)

The addon comes with a pre-configured `ProductQueryBuilder` fieldtype for immediate use:

```
# In your blueprint
fields:
  product_filter:
    type: product_query_builder
    display: Product Filter
    instructions: Build complex product queries visually
```

### Custom Query Builder

[](#custom-query-builder)

Create a custom query builder for your specific needs:

```

import QueryBuilder from './QueryBuilder.vue';

export default {
    components: { QueryBuilder },
    mixins: [Fieldtype],

    data() {
        return {
            groupedFields: [
                {
                    label: 'Product Attributes',
                    options: [
                        {
                            label: 'Product Name',
                            value: 'name',
                            type: 'text'
                        },
                        {
                            label: 'Category',
                            value: 'category',
                            type: 'select',
                            options: [
                                { label: 'Electronics', value: 'electronics' },
                                { label: 'Clothing', value: 'clothing' }
                            ]
                        },
                        {
                            label: 'Price',
                            value: 'price',
                            type: 'number'
                        },
                        {
                            label: 'Created Date',
                            value: 'created_at',
                            type: 'date'
                        }
                    ]
                },
                {
                    label: 'Stock Information',
                    options: [
                        {
                            label: 'Stock Status',
                            value: 'stock_status',
                            type: 'select',
                            operators: ['=', '!='],
                            options: [
                                { label: 'In Stock', value: 'in_stock' },
                                { label: 'Out of Stock', value: 'out_of_stock' }
                            ]
                        }
                    ]
                }
            ],
            templates: [
                { label: 'Product Slider', value: 'slider' },
                { label: 'Product Grid', value: 'listing' }
            ]
        }
    }
}

```

Supported Field Types &amp; Operators
-------------------------------------

[](#supported-field-types--operators)

### Text Fields

[](#text-fields)

- `=` - Exactly equals
- `!=` - Does not equal
- `LIKE` - Contains text
- `NOT LIKE` - Does not contain
- `STARTS_WITH` - Begins with
- `ENDS_WITH` - Ends with
- `IS_NULL` - Field is empty
- `IS_NOT_NULL` - Field has value

### Select Fields

[](#select-fields)

- `=` - Equals selected value
- `!=` - Does not equal
- `IN` - Is any of (multiple selection)
- `NOT IN` - Is none of (multiple selection)
- `IS_NULL` - Nothing selected
- `IS_NOT_NULL` - Has selection

### Number Fields

[](#number-fields)

- `=`, `!=` - Equality comparisons
- `>`, `=`, ``, `=`, ` [
        'resources/query-presets/products.json',
        'resources/query-presets/categories.json',
    ]
];
```

Output Format
-------------

[](#output-format)

The query builder generates structured output perfect for Elasticsearch:

```
{
    "groups": [
        {
            "conjunction": "AND",
            "conditions": [
                {
                    "attribute": "attribute.brand",
                    "operator": "IN",
                    "value": ["nike", "adidas"]
                },
                {
                    "attribute": "price",
                    "operator": "BETWEEN",
                    "value": ["100", "500"]
                }
            ]
        }
    ],
    "globalConjunction": "AND",
    "limit": 50,
    "sortField": "created_at",
    "sortDirection": "DESC",
    "builderTemplate": "listing"
}
```

This gets automatically converted to Elasticsearch DSL:

```
{
    "query": {
        "bool": {
            "must": [
                {
                    "terms": {
                        "attribute.brand.keyword": ["nike", "adidas"]
                    }
                },
                {
                    "range": {
                        "price": {
                            "gte": 100,
                            "lte": 500
                        }
                    }
                }
            ]
        }
    },
    "size": 50,
    "from": 0
}
```

Templates
---------

[](#templates)

The chosen template is used to render the results of the query. You can include the right template in the blade template of your page builder item:

```
@include('rapidez-query-builder::templates.'. $product_query_builder->value()['builderTemplate'], $product_query_builder->value())
```

Configuration
-------------

[](#configuration)

### Product Attribute Model

[](#product-attribute-model)

Configure your product attribute model:

```
// config/rapidez/query-builder.php
return [
    'models' => [
        'product_attribute' => App\Models\ProductAttribute::class,
    ]
];
```

### Field Mappings

[](#field-mappings)

The addon automatically maps Elasticsearch field types:

- `text` fields → `.keyword` for exact matches
- `stock_status` → `in_stock` in Elasticsearch
- Attribute fields → `attribute.{attribute_code}` prefix

Requirements
------------

[](#requirements)

- PHP ^8.0
- Laravel ^9.0|^10.0|^11.0
- Statamic ^4.0|^5.0
- Rapidez framework
- Elasticsearch (via [Rapidez Laravel Elasticsearch package](https://github.com/rapidez/laravel-scout-elasticsearch))

Contributing
------------

[](#contributing)

Contributions are welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details.

License
-------

[](#license)

This package is open-sourced software licensed under the [MIT license](LICENSE.md).

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance79

Regular maintenance activity

Popularity22

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 52.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~26 days

Recently: every ~13 days

Total

12

Last Release

182d ago

Major Versions

1.1.0 → 2.0.02025-09-09

1.x-dev → 2.1.02025-09-23

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/72222911?v=4)[Rapidez](/maintainers/rapidez)[@rapidez](https://github.com/rapidez)

---

Top Contributors

[![kevinmeijer97](https://avatars.githubusercontent.com/u/9716909?v=4)](https://github.com/kevinmeijer97 "kevinmeijer97 (20 commits)")[![royduin](https://avatars.githubusercontent.com/u/1703233?v=4)](https://github.com/royduin "royduin (12 commits)")[![BobWez98](https://avatars.githubusercontent.com/u/23509926?v=4)](https://github.com/BobWez98 "BobWez98 (3 commits)")[![Jade-GG](https://avatars.githubusercontent.com/u/32514269?v=4)](https://github.com/Jade-GG "Jade-GG (2 commits)")[![indykoning](https://avatars.githubusercontent.com/u/15870933?v=4)](https://github.com/indykoning "indykoning (1 commits)")

---

Tags

rapidezstatamic-query-builder

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/rapidez-statamic-query-builder/health.svg)

```
[![Health](https://phpackages.com/badges/rapidez-statamic-query-builder/health.svg)](https://phpackages.com/packages/rapidez-statamic-query-builder)
```

###  Alternatives

[statamic/ssg

Generate static sites with Statamic.

254302.4k](/packages/statamic-ssg)[statamic/seo-pro

65440.7k](/packages/statamic-seo-pro)[jacksleight/statamic-bard-texstyle

17172.5k](/packages/jacksleight-statamic-bard-texstyle)[marcorieser/statamic-livewire

A Laravel Livewire integration for Statamic.

2381.5k10](/packages/marcorieser-statamic-livewire)[withcandour/aardvark-seo

Save time and get your Statamic site to rank better with the SEO addon for Statamic.

13128.3k](/packages/withcandour-aardvark-seo)[alt-design/alt-sitemap

Alt Sitemap addon, create a sitemap from Statamic entries

1219.0k](/packages/alt-design-alt-sitemap)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
