Skip to content

Latest commit

 

History

History
129 lines (103 loc) · 2.76 KB

README.md

File metadata and controls

129 lines (103 loc) · 2.76 KB

Elasticsearch Mapper WKT Plugin

This is a plugin for Elasticsearch. It allows the use of WKT for indexing Geo Shapes in Elasticsearch.

After indexing, the Elasticsearch Query DSL for Geo Shapes can be used normally.

Installation

You need Apache Maven to build and package the plugin.

Run the following in the project root directory:

mvn clean package

This will create a zipped plugin under [mapper-wkt-home]/target/releases.

Then, in [elasticsearch_home] install the plugin:

./bin/plugin install file:///path/to/plugin.zip

or, on Windows:

.bin\plugin.bat install file:///path/to/plugin.zip

If it was running, restart the node after installing.

Regular scenario

Create index with geo mappings:

PUT http://localhost:9200/my_index
{
  "mappings": {
    "my_type": {
      "properties": {
        "name": {
          "type": "string"
        },
        "location": {
          "type": "geo_shape"
        }
      }
    }
  }
}

Load data:

PUT http://localhost:9200/my_index/my_type/1
{
  "name": "Wind & Wetter, Berlin, Germany",
  "location": {
    "type": "point",
    "coordinates": [13.400544, 52.530286]
  }
}

Desired scenario

Create index with geo mappings:

PUT http://localhost:9200/my_index
{
  "mappings": {
    "my_type": {
      "properties": {
        "name": {
          "type": "string"
        },
        "location": {
          "type": "wkt"
        }
      }
    }    
  }
}

Load data:

PUT http://localhost:9200/my_index/my_type/1
{
  "name": "Wind & Wetter, Berlin, Germany",
  "location": "POINT (13.400544 52.530286)"
}

Test query

Test the result of the above loading scenarios:

POST http://localhost:9200/my_index/my_type/_search
{
  "query":{
    "bool": {
      "must": {
        "match_all": {}
      },
      "filter": {
        "geo_shape": {
          "location": {
            "shape": {
              "type": "envelope",
              "coordinates" : [[13.0, 53.0], [14.0, 52.0]]
            },
            "relation": "within"
          }
        }
      }
    }
  }
}

Links