Skip to content

pmaria/elasticsearch-mapper-wkt-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages