ngageoint / elasticgeo

ElasticGeo provides a GeoTools data store that allows geospatial features from an Elasticsearch index to be published via OGC services using GeoServer.
GNU General Public License v3.0
169 stars 85 forks source link

Geometry null after publishing the ES layer in geoserver #16

Closed francbartoli closed 8 years ago

francbartoli commented 8 years ago

After loading a shapefile with the ogr2ogr driver:

ogr2ogr -progress -lco INDEX_NAME=elasticday -lco MAPPING_NAME=mfermate -lco FID=ID -lco GEOMETRY_NAME=geometry -lco GEOM_MAPPING_TYPE=GEO_POINT -s_srs EPSG:32632 -t_srs EPSG:4326 -f "ElasticSearch" http://localhost:9200 MM_FERM.shp

I see it properly created in the index but when I try to publish into GS the BBOX is not recognized and a WFS call simply shows all the geometry null

OLD INDEX

{
type: "FeatureCollection",
totalFeatures: 62,
features: [
{
type: "Feature",
id: "FeatureCollection.AU9A-d1J6YOE6h8Y-HMf",
geometry: {
type: "Point",
coordinates: [
7.452106982623389,
45.75726559555538
]
},
geometry_name: "geometry.coordinates",
properties: {
_id: "AU9A-d1J6YOE6h8Y-HMf",
_index: "nivozone_clean",
_type: "FeatureCollection",
_score: 1,
_relative_score: 1,
_timestamp: null,
properties.id: 3,
properties.Area: 941.9758,
properties.Nome: "Valle d'Aosta Centrale",
properties.Nivozone: "IT9",
type: "Feature",
geometry.type: "POINT"
}
},

NEW INDEX

{
type: "FeatureCollection",
totalFeatures: 62,
features: [
{
type: "Feature",
id: "Nivozone.AU89hPGz6YOE6h8Y-HLd",
geometry: null,
geometry_name: "geometry.coordinates",
properties: {
_id: "AU89hPGz6YOE6h8Y-HLd",
_index: "nivozone",
_type: "FeatureCollection",
_score: 1,
_relative_score: 1,
_timestamp: null,
properties.id: 4,
properties.Meteonivoz: "IT48R1",
properties.Area_MNZ: 631.0047,
properties.Nome: "Alpi Pennine",
type: "Feature",
geometry.type: "POINT",
geometry.coordinates: null
}
},

I've attempted with different environment and I've got the same result:

OSX 10.9.5 JVM 1.7 OpenGeo Suite 4.8 (GeoServer 2.8-SNAPSHOT) ELASTICGEO 2.8-SNAPSHOT (successfully compiled from source) ES 2.2

UBUNTU 14.04 JVM 1.7 TOMCAT 7 GEOSERVER 2.8.3 ELASTICGEO Precompiled 2.8.3 ES 2.2

Incidentally I've in the same ES cluster an index created with the 1.7 version and the plugin is able to create layers from that with the expected geometries.

sjudeng commented 8 years ago

Thanks for the bug report. Can you try pulling and building the latest code? I just pushed an update to hopefully resolve this issue.

francbartoli commented 8 years ago

@sjudeng tested your latest code but the issue is still there

sjudeng commented 8 years ago

I'm not able to reproduce this anymore (I could initially, before the latest commit). Tested with elasticsearch-2.2.2 and geoserver-2.8.3 (see below). Make sure you've done a clean build from source and removed the previous version.

ogr2ogr -lco INDEX_NAME=bugsites -lco MAPPING_NAME=bugsites -lco FID=ID -lco GEOMETRY_NAME=geometry -lco GEOM_MAPPING_TYPE=GEO_POINT -s_srs EPSG:26713 -t_srs EPSG:4326 -f "ElasticSearch" http://localhost:9200 geoserver/data/data/sf/bugsites.shp

http://localhost:8080/geoserver/test/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=test:bugsites&maxFeatures=50

elasticgeo_issue16

francbartoli commented 8 years ago

I did a clean install. This is my request output in debug mode:

2016-06-15 21:00:10,283 DEBUG [org.geotools.util] - InterpolationConverterFactory can be applied from Strings to Interpolation  only.
2016-06-15 21:00:10,288 INFO [org.geoserver.wfs] -
Request: getServiceInfo
2016-06-15 21:00:10,551 INFO [org.geoserver.wfs] -
Request: getFeature
    service = WFS
    version = 1.0.0
    baseUrl = http://localhost:8080/geoserver/
    query[0]:
        typeName[0] = {http://opengeo.org}mfermate
    maxFeatures = 50
    outputFormat = application/json
    resultType = results
2016-06-15 21:00:10,613 INFO [org.geoserver.wfs.json] - about to encode JSON
2016-06-15 21:00:10,647 DEBUG [org.geotools.util] - InterpolationConverterFactory can be applied from Strings to Interpolation only.
2016-06-15 21:00:10,647 DEBUG [org.geotools.util] - CRSConverterFactory can be applied from Strings to CRS  only.

Did not have time to have a look at the code but the last messages are the expected behavior in your code? Do you have the same in your environment?

francbartoli commented 8 years ago

@sjudeng forgot my messages, I'm a stupid man. I did the clean install from the web directory instead from the root pom

francbartoli commented 8 years ago

Now work properly. However I had to set this startup parameter to avoid a class not loading:

-DGEOSERVER_XSTREAM_WHITELIST=mil.nga.giat.data.elasticsearch.ElasticAttribute

Does make sense to add in the docs?

sjudeng commented 8 years ago

I just pushed one more commit on this. While the original fix addressed the mapping and feature reading issue, in further testing I found filtering wasn't working properly for this case. Should be okay now.

The XStream environment variable shouldn't be necessary. Can you provide steps to reproduce the relevant exception you're seeing? If so, please open a new issue for this.