Coder Social home page Coder Social logo

spoddutur / rdf-graph-search-with-solr-custom-streaming-expression Goto Github PK

View Code? Open in Web Editor NEW
7.0 2.0 2.0 39 KB

SolrCloud RDF store to find entity-relations via solr 6.6.2 custom streaming query

Java 100.00%
solr custom-streaming-expression rdf graph spo search-algorithm entity-links graph-traversal linked-data

rdf-graph-search-with-solr-custom-streaming-expression's Introduction

rdf-graph-search-with-solr-custom-streaming-expression

  • Given a RDF graph indexed in Solr 6.6.2, a custom streaming query paths()was implemented to find connections between any two entities in the RDF graph.
  • paths(from, to) query will return all the paths connecting 'from' and 'to' as per solr index.
  • Returns results in sub-second :)..

1. Demo Time

  1. Let's index some sample data about billgates and microsoft
  2. Once the index is ready, search using paths() query to find all the paths connecting these two entities in this graph.

Let me walk you step-by-step starting from index to query and see the results

1.1 Sample Data

1.2 Sample Query

Find all connections between BillGates and Microsoft

      paths(rdf, 
      from="src_s->billgates",
      to="dst_s->microsoft",
      fl="src_s,dst_s,relation_s")

image

1.3 Sample Query Results

Found 4 different paths connecting billgates and microsoft

2. Architecture and Features:

  • Merges search with parallel computing (paralelly computes query in all shards and merges the results).
  • Fully Streaming.
  • SolrCloud aware.

image

2.1 Query syntax:

paths(<collectionName>, 
      from="fromField->fromNode",
      to="toField->toNode",
      fl="<csv of fields to return per matching document>",
      maxDepth="<maximum depth to go searching for toNode starting from fromNode>")

3. Compile and Run

3.1 Generate jar file

mvn clean package generates jar file.

3.2 Create .system collection

curl 'http://localhost:8983/solr/admin/collections?action=CREATE&name=.system'
curl http://localhost:8983/solr/.system/config -d '{"set-user-property": {"update.autoCreateFields":"false"}}'

3.3 Upload jar file to .system collection

curl -X POST -H 'Content-Type: application/octet-stream' --data-binary @rdf-graph-search-with-solr-custom-streaming-expression-1.0-SNAPSHOT.jar 'http://localhost:8983/solr/.system/blob/test'

3.4 Verify that this jar is uploaded under the name 'test' in .system collection

curl 'http://localhost:8983/solr/.system/blob?omitHeader=true'

3.5 Add our jar as runtime-lib to test collection

curl 'http://localhost:8983/solr/test/config' -H 'Content-type:application json' -d '{   "add-runtimelib": { "name":"test", "version":1 }}'

3.6 Register our paths() custom streaming expression with test collection

curl 'http://localhost:8983/solr/rdf/config' -H 'Content-type:application/json' -d '{
  "create-expressible": {
    "name": "paths",
    "class": "com.solr.custom.streaming.PathsStreamingExpression",
    "runtimeLib": true
  }
}'

Tht's it!! Now, navigate to "stream" tab of test collection in SolrAdmin page and run your query..

4. How to update solr about any changes done to the jar?

4.1 Upload new jar with changes again

curl -X POST -H 'Content-Type: application/octet-stream' --data-binary @custom-streaming-expression-1.0-SNAPSHOT.jar 'http://localhost:8983/solr/.system/blob/test'

4.2 Check the new version number.

Now you should see that the jar version number has increased by 1. Let's say the version is now increased from 1 to 2.

curl 'http://localhost:8983/solr/.system/blob?omitHeader=true'

4.3 Update 'test' collection to use version 2 of our jar

curl 'http://localhost:8983/solr/test/config' -H 'Content-type:application json' -d '{   "update-runtimelib": { "name":"test", "version":2 }}'

No need to restart solr. Your changes are reflected and you can start querying solr to test your results.

4.4. How to remove the custom expression from a collection

curl 'http://localhost:8983/solr/test/config' -H 'Content-type:application/json' -d '{
  "delete-expressible": "mysearch"
}'

rdf-graph-search-with-solr-custom-streaming-expression's People

Contributors

spoddutur avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

wasim24 myownr

rdf-graph-search-with-solr-custom-streaming-expression's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.