Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Elasticsearch Dsl Laravel Package

ongr/elasticsearch-dsl

Object-oriented Elasticsearch query builder for PHP. Build searches, filters, aggregations and more with a DSL, then export to arrays for elasticsearch-php or ONGR ElasticsearchBundle. Supports Elasticsearch 5/6/7 via versioned releases.

View on GitHub
Deep Wiki
Context7

Derivative Aggregation

More info about derivative aggregation is in the official elasticsearch docs

A parent pipeline aggregation which calculates the derivative of a specified metric in a parent histogram (or date_histogram) aggregation. The specified metric must be numeric and the enclosing histogram must have min_doc_count set to 0 (default for histogram aggregations).

Simple example

{
    "aggs" : {
        "sales_per_month" : {
            "date_histogram" : {
                "field" : "date",
                "interval" : "month"
            },
            "aggs": {
                "sales": {
                    "sum": {
                        "field": "price"
                    }
                },
                "sales_deriv": {
                    "derivative": {
                        "buckets_path": "sales" 
                    }
                }
            }
        }
    }
}

And now the query via DSL:

$dateAggregation = new DateHistogramAggregation('sales_per_month', 'date', 'month');
$sumAggregation = new SumAggregation('sales', 'price');
$derivativeAggregation = new DerivativeAggregation('sales_deriv', 'sales');
$dateAggregation->addAggregation($sumAggregation);
$dateAggregation->addAggregation($derivativeAggregation);

$search = new Search();
$search->addAggregation($dateAggregation);

$queryArray = $search->toArray();

Second order derivative

Somewhat more complex would be an example of a second order derivatives. This functionality is presented in the folowing example:

{
    "aggs" : {
        "sales_per_month" : {
            "date_histogram" : {
                "field" : "date",
                "interval" : "month"
            },
            "aggs": {
                "sales": {
                    "sum": {
                        "field": "price"
                    }
                },
                "sales_deriv": {
                    "derivative": {
                        "buckets_path": "sales"
                    }
                },
                "sales_2nd_deriv": {
                    "derivative": {
                        "buckets_path": "sales_deriv" 
                    }
                }
            }
        }
    }
}

And now via DSL:

$dateAggregation = new DateHistogramAggregation('sales_per_month', 'date', 'month');
$sumAggregation = new SumAggregation('sales', 'price');
$firstDerivativeAggregation = new DerivativeAggregation('sales_deriv', 'sales');
$secondDerivativeAggregation = new DerivativeAggregation('sales_2nd_deriv', 'sales_deriv');

$dateAggregation->addAggregation($sumAggregation);
$dateAggregation->addAggregation($firstDerivativeAggregation);
$dateAggregation->addAggregation($secondDerivativeAggregation);

$search = new Search();
$search->addAggregation($dateAggregation);

$queryArray = $search->toArray();

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
emuniq/filament-browser-notifications
syriable/filament-translator
hungnm28/livewire-form
wenprise/eloquent
crudly/encrypted
fadion/bouncy
cuci/prototurk-sdk
gos/pubsub-router-bundle
cuci/prototurk-sdk-symfony
clementtalleu/easyadmin-markdown-bundle
codeflextech/permission-manager
karnoweb/livewire-datepicker
sayedenam/sayed-dashboard
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui