Evangelos
Evangelos

Reputation: 39

GraphDB Elasticsearch Connector

is there a working example to map lat long properties from graphdb to geo_point objects on elastic search ?

{
              "fieldName": "location",
              "propertyChain": [
                "http://example.com/coordinates"
              ],
              "objectFields": [
                {
                  "fieldName": "lat",
                  "propertyChain": [
                    "http://www.w3.org/2003/01/geo/wgs84_pos#lat"
                  ]
                },
                {
                  "fieldName": "lon",
                  "propertyChain": [
                    "http://www.w3.org/2003/01/geo/wgs84_pos#long"
                  ]
                }
              ]
            }

thanks

Upvotes: 1

Views: 293

Answers (1)

Pavel Mihaylov
Pavel Mihaylov

Reputation: 361

The only way to index data as geo_point with the current version of GraphDB and the Elasticsearch connector is to have the latitude and the longitude in a single literal, e.g. with the property http://www.w3.org/2003/01/geo/wgs84_pos#lat_long. The connector would look like this:

PREFIX : <http://www.ontotext.com/connectors/elasticsearch#>
PREFIX inst: <http://www.ontotext.com/connectors/elasticsearch/instance#>
INSERT DATA {
  inst:geopoint :createConnector '''
    {
      "elasticsearchNode": "localhost:9300",
      "types": ["http://geopoint.ontotext.com/Point"],
      "fields": [
        {
          "fieldName": "location",
          "propertyChain": [
            "http://www.w3.org/2003/01/geo/wgs84_pos#lat_long"
          ],
          "datatype": "native:geo_point"
        }
      ],
    }
  ''' .
}

Note that datatype: "native:geo_point" is important as it tells Elasticsearch what type of data this is.

We are currently looking into possible ways to introduce support for latitude and longitude coming from separate literals.

Upvotes: 2

Related Questions