Semantic Search gets the power of Full Text Search

 

Pre-requisites:

  1. An installed instance of GraphDB (currently only the OntoText Enterprise edition has connectors)
  2. An installed instance of Elasticsearch
    1. With port 9300 open and running (this can be configured in */config/elasticsearch.yml or through your puppet/chef)
    2. If you are running this on Vagrant ensure all ports are forwarded to your host [9200, 9300, 12055 etc]

 

Prepare GraphDB

  1. Setup GraphDB location

Setup Repository and switch it on to default

GrapghDB Locations And Repo

Create Elasticsearch Connector

  1. Go to the SPARQL tab
  2. Insert your query like bellow and hit run

 

[code language=”bash”]

PREFIX : <http://www.ontotext.com/connectors/elasticsearch#>
PREFIX inst: <http://www.ontotext.com/connectors/elasticsearch/instance#>

INSERT DATA {inst:my_index :createConnector ”’
{
"elasticsearchCluster": "vagrant",
"elasticsearchNode": "localhost:9300",
"types": ["http://www.ontotext.com/example/wine#Wine"],
"fields": [
{"fieldName": "grape",
"propertyChain": [
"http://www.ontotext.com/example/wine#madeFromGrape",
"http://www.w3.org/2000/01/rdf-schema#label"
]},
{"fieldName": "sugar",
"propertyChain": [
"http://www.ontotext.com/example/wine#hasSugar"
],"orderBy": true},
{"fieldName": "year",
"propertyChain": [
"http://www.ontotext.com/example/wine#hasYear"
]}]}
”’ .
}
[/code]

3.  Go over to Elasticsearch and confirm that you have a newly created index [my_index], this will be empty for now

4.  Example debugging to do is check for the listed Connectors and its status:

[code language=”bash”]

PREFIX : <http://www.ontotext.com/connectors/elasticsearch#>

SELECT ?cntUri ?cntStr {
?cntUri :listConnectors ?cntStr .
}
[/code]

[code language=”bash”]

PREFIX : <http://www.ontotext.com/connectors/elasticsearch#>

SELECT ?cntUri ?cntStatus {
?cntUri :connectorStatus ?cntStatus .
}
[/code]

 

Insert Data in GraphDB

 

  1. The Connector should listen in for any data changes and insert/update/sync the accompanying elastic copy.

 

[code language=”bash”]

@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix : <http://www.ontotext.com/example/wine#> .

:RedWine rdfs:subClassOf :Wine .
:WhiteWine rdfs:subClassOf :Wine .
:RoseWine rdfs:subClassOf :Wine .

:Merlo
rdf:type :Grape ;
rdfs:label "Merlo" .

:CabernetSauvignon
rdf:type :Grape ;
rdfs:label "Cabernet Sauvignon" .

:CabernetFranc
rdf:type :Grape ;
rdfs:label "Cabernet Franc" .

:PinotNoir
rdf:type :Grape ;
rdfs:label "Pinot Noir" .

:Chardonnay
rdf:type :Grape ;
rdfs:label "Chardonnay" .

:Yoyowine
rdf:type :RedWine ;
:madeFromGrape :CabernetSauvignon ;
:hasSugar "dry" ;
:hasYear "2013"^^xsd:integer .

:Franvino
rdf:type :RedWine ;
:madeFromGrape :Merlo ;
:madeFromGrape :CabernetFranc ;
:hasSugar "dry" ;
:hasYear "2012"^^xsd:integer .

:Noirette
rdf:type :RedWine ;
:madeFromGrape :PinotNoir ;
:hasSugar "medium" ;
:hasYear "2012"^^xsd:integer .

:Blanquito
rdf:type :WhiteWine ;
:madeFromGrape :Chardonnay ;
:hasSugar "dry" ;
:hasYear "2012"^^xsd:integer .

:Rozova
rdf:type :RoseWine ;
:madeFromGrape :PinotNoir ;
:hasSugar "medium" ;
:hasYear "2013"^^xsd:integer .
[/code]

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


Leave a Reply

Your email address will not be published. Required fields are marked *