This document discusses GraphDB connectors, which implement advanced search scenarios for GraphDB. It describes how the connectors allow real-time synchronization with external data stores, support for property chains and full-text search, and integration with SPARQL queries. The connectors are designed to optimize the filtering of large, complex models to retrieve results fast.
1 of 42
Downloaded 16 times
More Related Content
Ontotext's GraphDB Connectors
1. GraphDB Connectors
Nikola Petrov<nikola.petrov@ontotext.com>
Ontotext AD
September 8, 2014
Nikola Petrov<nikola.petrov@ontotext.com> GraphDB Connectors
2. OWLIM GraphDB Family
GRAPHDB Server - the database engine
GRAPHDB Workbench - tool support that replaces the sesame
workbench
GRAPHDB Connectors - implements advanced search scenarios
Nikola Petrov<nikola.petrov@ontotext.com> GraphDB Connectors
3. Why? What we are trying to solve
Our models are really rich/complex but we still want to get the
results fast
Nikola Petrov<nikola.petrov@ontotext.com> GraphDB Connectors
4. Why? What we are trying to solve
Our models are really rich/complex but we still want to get the
results fast
Most of the queries in the search space are of the form:
SELECT < p r o j e c t i o n var iables >
WHERE {
{
. . . many t r i p l e pat terns to f i l t e r data . . .
. . . p o t e n t i a l l y regex or f u l l t e x t search . . .
}
. . .
{
. . . many t r i p l e pat terns to r e t r i e v e data . . .
. . . of ten many o p t i o n a l and aggregates . . .
}
}
Nikola Petrovnikola.petrov@ontotext.com GraphDB Connectors
5. Why? What we are trying to solve
Our models are really rich/complex but we still want to get the
results fast
Most of the queries in the search space are of the form:
SELECT p r o j e c t i o n var iables
WHERE {
{
. . . many t r i p l e pat terns to f i l t e r data . . .
. . . p o t e n t i a l l y regex or f u l l t e x t search . . .
}
. . .
{
. . . many t r i p l e pat terns to r e t r i e v e data . . .
. . . of ten many o p t i o n a l and aggregates . . .
}
}
We want to optimize the filtering part
Nikola Petrovnikola.petrov@ontotext.com GraphDB Connectors
8. How it all started
Analyzed all major production systems projects
Collected feedback from partners
Reused features and know-how from multiple projects
Nikola Petrovnikola.petrov@ontotext.com GraphDB Connectors
9. Main Features
Real time synchronization
Property chains support (data denormalization)
Full-text search and result snippets
Facet and co-occurrence
Visual interface for index creation
Everything is integrated in SPARQL
Nikola Petrovnikola.petrov@ontotext.com GraphDB Connectors
11. Real time synchronization
Create a link with a special predicate and we are going to
index/synchronize resources in the external store
PREFIX : http://www.ontotext.com/connectors/elasticsearch#
PREFIX inst: http://www.ontotext.com/connectors/elasticsearch/instance#
INSERT DATA{
inst:my_index :createConnector
# tell us what resources you want to index and which predicate
# values about them. We support predicate chains if the properties of
# the resource are not direct
}
Nikola Petrovnikola.petrov@ontotext.com GraphDB Connectors
12. Real time synchronization
Create a link with a special predicate and we are going to
index/synchronize resources in the external store
PREFIX : http://www.ontotext.com/connectors/elasticsearch#
PREFIX inst: http://www.ontotext.com/connectors/elasticsearch/instance#
INSERT DATA{
inst:my_index :createConnector
# tell us what resources you want to index and which predicate
# values about them. We support predicate chains if the properties of
# the resource are not direct
}
When you add/change resources that match the criteria, we will
automatically update the external store
Nikola Petrovnikola.petrov@ontotext.com GraphDB Connectors
13. Real time synchronization
Create a link with a special predicate and we are going to
index/synchronize resources in the external store
PREFIX : http://www.ontotext.com/connectors/elasticsearch#
PREFIX inst: http://www.ontotext.com/connectors/elasticsearch/instance#
INSERT DATA{
inst:my_index :createConnector
# tell us what resources you want to index and which predicate
# values about them. We support predicate chains if the properties of
# the resource are not direct
}
When you add/change resources that match the criteria, we will
automatically update the external store
Note
This might slow your insert statements a little bit(our tests show that this time is
negligible)
Nikola Petrovnikola.petrov@ontotext.com GraphDB Connectors
14. Example data with wines
Nikola Petrovnikola.petrov@ontotext.com GraphDB Connectors
15. Example data with wines
Nikola Petrovnikola.petrov@ontotext.com GraphDB Connectors
19. But wait, I dont understand all this json stuff...
Nikola Petrovnikola.petrov@ontotext.com GraphDB Connectors
20. But wait, I dont understand all this json stuff...
Nikola Petrovnikola.petrov@ontotext.com GraphDB Connectors
21. Elasticsearch index
Given our wines small dataset, here is what will get indexed in
elasticsearch
wine year grape sugar
:Yoyowine 2013 Cabernet Sauvignon dry
:Noirette 2012 Pinot Noir medium
:Blanquito 2012 Chardonnay dry
:Franvino 2012 Merlo, Cabernet Franc dry
:Rozova 2013 Pinot Noir medium
Nikola Petrovnikola.petrov@ontotext.com GraphDB Connectors
22. You can query the index and join the results in SPARQL
PREFIX : http://www.ontotext.com/connectors/elasticsearch#
PREFIX inst: http://www.ontotext.com/connectors/elasticsearch/instance#
SELECT ?entity {
?search a inst:index-name ;
:query full-text-query ;
:entities ?entity .
# Do anything you want with the bound entity
}
Nikola Petrovnikola.petrov@ontotext.com GraphDB Connectors
23. Get wines that are made from cabernet grape
PREFIX : http://www.ontotext.com/connectors/elasticsearch#
PREFIX inst: http://www.ontotext.com/connectors/elasticsearch/instance#
PREFIX wine: http://www.ontotext.com/example/wine#
SELECT ?wine ?year {
?search a inst:wines ;
:query grape:cabernet ;
:entities ?wine .
# We combine the results from elasticsearch and join them in graphdb
?wine wine:hasYear ?year
}
Nikola Petrovnikola.petrov@ontotext.com GraphDB Connectors
24. Get wines that are made from cabernet grape
PREFIX : http://www.ontotext.com/connectors/elasticsearch#
PREFIX inst: http://www.ontotext.com/connectors/elasticsearch/instance#
PREFIX wine: http://www.ontotext.com/example/wine#
SELECT ?wine ?year {
?search a inst:wines ;
:query grape:cabernet ;
:entities ?wine .
# We combine the results from elasticsearch and join them in graphdb
?wine wine:hasYear ?year
}
Wine Year
:Yoyowine 2013
:Franvino 2012
Nikola Petrovnikola.petrov@ontotext.com GraphDB Connectors
25. Other things that we expose for the matches
The matching snippet for the full-text query
Nikola Petrovnikola.petrov@ontotext.com GraphDB Connectors
26. Other things that we expose for the matches
The matching snippet for the full-text query
The score from elasticsearch for the match
Nikola Petrovnikola.petrov@ontotext.com GraphDB Connectors
27. Other things that we expose for the matches
The matching snippet for the full-text query
The score from elasticsearch for the match
Total number of hits in the external store
Nikola Petrovnikola.petrov@ontotext.com GraphDB Connectors
28. Other things that we expose for the matches
The matching snippet for the full-text query
The score from elasticsearch for the match
Total number of hits in the external store
Ordering the external store results
Nikola Petrovnikola.petrov@ontotext.com GraphDB Connectors
29. Faceting Usecase LCIE Co-occurrence
Nikola Petrovnikola.petrov@ontotext.com GraphDB Connectors
30. Faceting Usecase LCIE Co-occurrence
Nikola Petrovnikola.petrov@ontotext.com GraphDB Connectors
31. Faceting Usecase LCIE Facets and Full-text
Nikola Petrovnikola.petrov@ontotext.com GraphDB Connectors
32. Faceting Usecase LCIE Facets and Full-text
Nikola Petrovnikola.petrov@ontotext.com GraphDB Connectors
34. Faceting Usecase
PREFIX : http://www.ontotext.com/connectors/elasticsearch#
PREFIX inst: http://www.ontotext.com/connectors/elasticsearch/instance#
SELECT ?facetName ?facetValue ?facetCount WHERE{
# note empty query is allowed and will just match all documents, hence no :query
?r a inst:wines_index ;
:facetFields year,sugar ;
:facets _:f .
_:f :facetName ?facetName .
_:f :facetValue ?facetValue .
_:f :facetCount ?facetCount .
}
Nikola Petrovnikola.petrov@ontotext.com GraphDB Connectors
35. Faceting Usecase
PREFIX : http://www.ontotext.com/connectors/elasticsearch#
PREFIX inst: http://www.ontotext.com/connectors/elasticsearch/instance#
SELECT ?facetName ?facetValue ?facetCount WHERE{
# note empty query is allowed and will just match all documents, hence no :query
?r a inst:wines_index ;
:facetFields year,sugar ;
:facets _:f .
_:f :facetName ?facetName .
_:f :facetValue ?facetValue .
_:f :facetCount ?facetCount .
}
Facet Name Facet Value Facet Count
year 2012 3
year 2013 2
sugar dry 3
sugar medium 2
Nikola Petrovnikola.petrov@ontotext.com GraphDB Connectors
36. Entity filtering(Advanced topic)
A way to filter resources that land in the external store based the
field value
Nikola Petrovnikola.petrov@ontotext.com GraphDB Connectors
37. Entity filtering(Advanced topic)
A way to filter resources that land in the external store based the
field value
Allows you to use the same predicate/property chain for different
fields(based on a filter)
Nikola Petrovnikola.petrov@ontotext.com GraphDB Connectors
38. Entity filtering(Advanced topic)
A way to filter resources that land in the external store based the
field value
Allows you to use the same predicate/property chain for different
fields(based on a filter)
Consider the usecase of articles that reference people, locations,
etc
Nikola Petrovnikola.petrov@ontotext.com GraphDB Connectors
39. Entity filtering
PREFIX : http://www.ontotext.com/connectors/elasticsearch#
PREFIX inst: http://www.ontotext.com/connectors/elasticsearch/instance#
INSERT DATA {
inst:my_index :createConnector
{
elasticsearchNode: localhost:9200,
types: [http://www.ontotext.com/example2#Article],
fields: [
{
fieldName: comment,
propertyChain: [http://www.w3.org/2000/01/rdf-schema#comment]
},
{
fieldName: taggedWithPerson,
propertyChain: [http://www.ontotext.com/example2#taggedWith]
},
{
fieldName: taggedWithLocation,
propertyChain: [http://www.ontotext.com/example2#taggedWith]
}
],
entityFilter: ?taggedWithPerson type in
(http://www.ontotext.com/example2#Person)
?taggedWithLocation type in (http://www.ontotext.com/example2#Location)
}
.
}
Nikola Petrovnikola.petrov@ontotext.com GraphDB Connectors
40. Things that dont work right now but will in the near future
support for remote external stores(solr, elasticsearch) in graphdb
cluster setup
filtering anywhere in the property chain(we support only filtering
the indexed value)
filtering implicit from explicit statements
Nikola Petrovnikola.petrov@ontotext.com GraphDB Connectors
41. Query tree
Nikola Petrovnikola.petrov@ontotext.com GraphDB Connectors