Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Geohash filter #3218

Closed
chilling opened this issue Jun 24, 2013 · 0 comments
Closed

Geohash filter #3218

chilling opened this issue Jun 24, 2013 · 0 comments

Comments

@chilling
Copy link
Contributor

Geohashes provide a structure for geospatial subdivisions by defining a hierarchical grid. This data structure supports an efficient way to filter data in a hierarchical way which should be supported by the REST API to filter points of certain cell.
Such a filter just needs a geohash that defines a cell within the grid and will be used as prefix. In result of filtering data with a geohash filter all geopoints sharing the same prefix as the defined cell must be returned. Also such a filter should allow filtering adjacent cells of the defined cell. For example the cell defined by the geohash u30 has eight adjacent cells u1r, u32, u33, u1p, u31, u0z, u2b and u2c. So this kind of filter can be used for a more efficient filtering-process than the simple bounding box filter does.

Example

The most simple setup for such a filter uses two arguments:

  • the field of the document which holds the geohash
  • the actual geohash
curl -XGET 'http://127.0.0.1:9200/locations/_search?pretty=true' -d '{
    "query": {
        "match_all":{}
    },
    "filter": {
        "geohash_cell": {
            "field": "pin",
            "geohash": "u30",
        }
    }
}'

Since each geopoint corresponds to a single geohash it must be possible to index all prefixes of this geohash. For example the geohash u30 also corresponds to the terms u3 and u. The upper bound of the geohash length is defined by the precision defined in the mapping.

curl -XPUT 'http://127.0.0.1:9200/locations/?pretty=true' -d '{
    "mappings" : {
        "location": {
            "properties": {
                "pin": {
                    "type": "geo_point",
                    "geohash": true,
                    "geohash_prefix": true,
                    "geohash_precision", 12
                }
            }
        }
    }
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant