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

Significant Terms Aggregation

More info about histogram aggregation is in the official elasticsearch docs

An aggregation that returns interesting or unusual occurrences of terms in a set.

Simple example

{
    "query" : {
        "terms" : {"force" : [ "British Transport Police" ]}
    },
    "aggregations" : {
        "significantCrimeTypes" : {
            "significant_terms" : { "field" : "crime_type" }
        }
    }
}

And now the query via DSL:

$significantTermsAggregation = new SignificantTermsAggregation('significantCrimeTypes', 'crime_type');
$query = new TermsQuery('force', ['British Transport Police']);

$search = new Search();
$search->addQuery($query);
$search->addAggregation($histogramAggregation);

$queryArray = $search->toArray();

Multi-set Analysis

A simpler way to perform analysis across multiple categories is to use a parent-level aggregation to segment the data ready for analysis.


{
    "aggregations": {
        "forces": {
            "terms": {"field": "force"},
            "aggregations": {
                "significantCrimeTypes": {
                    "significant_terms": {"field": "crime_type"}
                }
            }
        }
    }
}

And now the query via DSL:


$significantTermsAggregation = new SignificantTermsAggregation('significantCrimeTypes', 'crime_type');
$termsAggregation = new TermsAggregation('forces', 'force');
$termsAggregation->addAggregation($significantTermsAggregation);

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

$queryArray = $search->toArray();

Other top level aggregations can be used to segment the data, for example, it can be segmented by geographic area to identify unusual hot-spots of a particular crime:


{
    "aggs": {
        "hotspots": {
            "geohash_grid" : {
                "field":"location",
                "precision":5,
            },
            "aggs": {
                "significantCrimeTypes": {
                    "significant_terms": {"field": "crime_type"}
                }
            }
        }
    }
}

And now via DSL:


$significantTermsAggregation = new SignificantTermsAggregation('significantCrimeTypes', 'crime_type');
$geoHashAggregation = new GeoHashGridAggregation('hotspots', 'location', 5);
$geoHashAggregation->addAggregation($significantTermsAggregation);

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

$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