[gdal-dev] Question about how GDAL makes an ElasticSearch index

Even Rouault even.rouault at spatialys.com
Wed Nov 23 05:11:24 PST 2016


On mercredi 23 novembre 2016 12:58:56 CET Rahkonen Jukka (MML) wrote:
> Hi,
> 
> It seems that all examples about how to query ElasticSearch with GDAL in
> http://www.gdal.org/drv_elasticsearch.html are failing with ElasticSearch
> versions 2.x.

That's likely. They were writte against 1.X. I didn't test againt 2.X myself apart from very basic 
test when integrating the patch that brought support for it.

> Reason is the breaking change "A field can no longer be
> referenced using its short name. Instead, the full path to the field is
> required" as documented in
> https://www.elastic.co/guide/en/elasticsearch/reference/2.0/breaking_20_map
> ping_changes.html
> 
> I am planning to update the documents but I would like to be sure that I
> have understood it right that:
> 
> -          GDAL creates an ElasticSearch index with the name = OGR layer
> name

By default yes. Unless the INDEX_NAME layer creation option is used.

"""*INDEX_NAME*=name. Name of the index to create (or reuse). By default the index name 
is the layer name."""

> 
> -          That ES index has always _type named FeatureCollection

When the layer is imported by OGR, yes. Unless the MAPPING_NAME layer creation option is 
used.

"""*MAPPING_NAME=*=name. Name of the mapping type within the index. By default, the 
mapping name is "FeatureCollection" and the documents will be written as GeoJSON Feature 
objects. If another mapping name is chosen, a more "flat" structure will be used."""

> 
> -          attributes of the source data are always within "properties"

If mapping_name == FeatureCollection, yes (using a GeoJSON Feature structure). Otherwise 
they are put at the root of the document.

> 
> Therefore this
> ogrinfo -ro ES: my_type -where '{ "filter": { "term": { "EAS_ID": 168 } } }'
> 
> must be used in this way with ES 2.x
> ogrinfo -ro ES: my_type -where '{ "filter": { "term": { "properties.EAS_ID":
> 168 } } }'

I guess that would work although for ES 1.x ? In which case we can mention only the new way 
to make things simpler.

> 
> similarly the Windows escaping example
> C:\GDAL_on_Windows>ogrinfo ES: my_type -where "{\"query\": { \"match\": {
> \"properties.NAME\": \"Helsinki\" } } }"

That works on Linux as well (it is just that the single quoting is convenient, especially since it 
can be used for multi line filters)

> 
> Do you agree?

Yes, thanks.

> 
> -Jukka Rahkonen-


-- 
Spatialys - Geospatial professional services
http://www.spatialys.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20161123/3a5fd15f/attachment.html>


More information about the gdal-dev mailing list