# A logstash input plugin to ingest RDF/graph data into elasticsearch?

**URL:** <https://discuss.elastic.co/t/a-logstash-input-plugin-to-ingest-rdf-graph-data-into-elasticsearch/166248>\
**Category:** Logstash\
**Created:** [January 30, 2019, 12:58am UTC](https://discuss.elastic.co/t/a-logstash-input-plugin-to-ingest-rdf-graph-data-into-elasticsearch/166248 "2019-01-30T00:58:29Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![vnktsh](https://avatars.discourse-cdn.com/v4/letter/v/db5fbb/32.png) [@vnktsh](https://discuss.elastic.co/u/vnktsh)\
**Post date:** [January 30, 2019, 12:58am UTC](https://discuss.elastic.co/t/a-logstash-input-plugin-to-ingest-rdf-graph-data-into-elasticsearch/166248/1 "2019-01-30T00:58:29Z")

</div>

Hello guys,

Recently I integrated Postgres data into Elasticsearch through Logstash via JDBC plugin. I have a graph DB (Apache Jena) which stores rdf data in a triplestore. Is there a plugin which can connect to this graph db and thereby export data to elasticserach?

So far I came across:  
[elasticsearch-plugin-rdf-jena](https://github.com/jprante/elasticsearch-plugin-rdf-jena) by jparte **[No longer supported for ES \> v1.4.0]**

[eea.elasticsearch.river.rdf](https://github.com/eea/eea.elasticsearch.river.rdf)  
**Based on rivers - deprecated**. Workaround is to host it in separate app.

Since I already have Logstash setup in our environment, I'm looking into Logstash plugins. If no plugins, can you direct how did you solve this problem?

---

<div class="post-metadata">

**Author:** ![danhermann](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/danhermann/32/33024_2.png) [@danhermann](https://discuss.elastic.co/u/danhermann)\
**Post date:** [January 30, 2019, 11:04am UTC](https://discuss.elastic.co/t/a-logstash-input-plugin-to-ingest-rdf-graph-data-into-elasticsearch/166248/2 "2019-01-30T11:04:12Z")

</div>

@vnktsh, have you considered using the [Logstash JDBC input](https://www.elastic.co/guide/en/logstash/current/plugins-inputs-jdbc.html) with the [Jena JDBC driver](https://jena.apache.org/documentation/jdbc/)?

---

<div class="post-metadata">

**Author:** ![vnktsh](https://avatars.discourse-cdn.com/v4/letter/v/db5fbb/32.png) [@vnktsh](https://discuss.elastic.co/u/vnktsh)\
**Post date:** [January 31, 2019, 3:02am UTC](https://discuss.elastic.co/t/a-logstash-input-plugin-to-ingest-rdf-graph-data-into-elasticsearch/166248/3 "2019-01-31T03:02:53Z")

</div>

Yes @danhermann, I tried and Logstash fails by sending an invalid sparql query over JDBC.

```
[2019-01-31T02:17:14,112][ERROR][logstash.inputs.jdbc] Java::JavaSql::SQLException: Not a valid SPARQL query: 
        SELECT count(*) AS "COUNT" FROM (
			select ?x ?y where {
                           ?x a <http://abc.com/ontologies/Test/1#X> .
                           ?y a <http://abc.com/ontologies/Test/1#Y> .
			}
		) AS "T1" LIMIT 1
[2019-01-31T02:17:14,119][WARN][logstash.inputs.jdbc] Exception when executing JDBC query {:exception=>#<Sequel::DatabaseError: Java::JavaSql::SQLException: Not a valid SPARQL query>}
[2019-01-31T02:17:14,119][WARN][logstash.inputs.jdbc] Attempt reconnection.
[2019-01-31T02:17:14,176][DEBUG][logstash.inputs.jdbc] closing {:plugin=>"LogStash::Inputs::Jdbc"}
[2019-01-31T02:17:14,177][DEBUG][logstash.pipeline] Input plugins stopped! Will shutdown filter/output workers.

```

As you can see, Logstash tries to get count of resultset by wrapping "**SELECT count(\*) AS "COUNT" FROM (**" over a _valid_ sparql query and making it an **invalid** one in the end.

This is a limitation of Logstash and JDBC input plugin, since on other sql clients like Squirrel I can perfectly use Jena JDBC driver to fetch sparql results. Is there a way I can get around it?

PS: This would have been correct and valid sparql query to get result count.

```
select (count(*) as ?count) {
    			select ?x ?y where {
                               ?x a <http://abc.com/ontologies/Test/1#X> .
                               ?y a <http://abc.com/ontologies/Test/1#Y> .
    			}
}
```

---

<div class="post-metadata">

**Author:** ![danhermann](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/danhermann/32/33024_2.png) [@danhermann](https://discuss.elastic.co/u/danhermann)\
**Post date:** [January 31, 2019, 12:19pm UTC](https://discuss.elastic.co/t/a-logstash-input-plugin-to-ingest-rdf-graph-data-into-elasticsearch/166248/4 "2019-01-31T12:19:42Z")

</div>

Unfortunately, there is currently no way to disable the attempt to obtain a record count in the JDBC input though there is an issue open about that:

> <https://github.com/logstash-plugins/logstash-input-jdbc/issues/305>

---

<div class="post-metadata">

**Author:** ![vnktsh](https://avatars.discourse-cdn.com/v4/letter/v/db5fbb/32.png) [@vnktsh](https://discuss.elastic.co/u/vnktsh)\
**Post date:** [January 31, 2019, 6:23pm UTC](https://discuss.elastic.co/t/a-logstash-input-plugin-to-ingest-rdf-graph-data-into-elasticsearch/166248/5 "2019-01-31T18:23:52Z")

</div>

Thanks for referencing the issue. I'll watch over it.

If not through Logstash, any way to to import data into elasticsearch? Only way I'm thinking of exporting it as json or to rdbms and then ingesting, but seems not ideal especially for my case where for syncing to happen every 10 min window.

---

<div class="post-metadata">

**Author:** ![danhermann](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/danhermann/32/33024_2.png) [@danhermann](https://discuss.elastic.co/u/danhermann)\
**Post date:** [February 1, 2019, 2:04am UTC](https://discuss.elastic.co/t/a-logstash-input-plugin-to-ingest-rdf-graph-data-into-elasticsearch/166248/6 "2019-02-01T02:04:04Z")

</div>

@vnktsh, if you can export to a file in JSON or to a DB, then it does open a range of possibilities for you. Logstash can definitely pull from either files or DBs. Depending on how the JSON export from Jena works, you might also be able to use [Filebeat](https://www.elastic.co/products/beats/filebeat) to send directly to Elasticsearch.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [March 1, 2019, 2:04am UTC](https://discuss.elastic.co/t/a-logstash-input-plugin-to-ingest-rdf-graph-data-into-elasticsearch/166248/7 "2019-03-01T02:04:07Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
