Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.

Geohash Cell Filter

More info about geohash cell filter is in the official elasticsearch docs

The geohash cell filter provides access to a hierarchy of geohashes. By defining a geohash cell, only geopoints within this cell will match this filter.

Simple example

{
    "filtered" : {
        "query" : {
            "match_all" : {}
        },
        "filter" : {
            "geohash_cell": {
                "pin": {
                    "lat": 13.4080,
                    "lon": 52.5186
                },
                "precision": 3,
                "neighbors": true
            }
        }
    }
}

And now the query via DSL:

$geohashCellFilter = new GeohashCellFilter(
    'pin',
    [
        'lat' => 13.4080,
        'lon' => 52.5186,
    ],
    [
        'precision' => 3,
        'neighbors' => true,
    ]
);

$search = new Search();
$search->addFilter($geohashCellFilter);

$queryArray = $search->toArray();