-
Notifications
You must be signed in to change notification settings - Fork 20
Java Client API
The module solrdf-client contains a Java client that can be used to interact with SolRDF. This has been mainly designed for hiding, as much as possible,
- the mixing of Jena (client side) and Solr (actually Solrj) code
- the interaction (including low level communication details) with a running SolRDF
As the client API development is currently in progress, the content of this chapter will be adjusted / corrected / changed according with the latest changes.
The fully name of the proxy is (not surprisingly) org.gazzax.labs.solrdf.client.SolRDF. It can be instantiated (at the moment) with several options, depending on the architecture of the target running SolRDF instance(s):
SolRDF solrdf = SolRDF.newBuilder()
.withEndpoint("http://127.0.0.1:8080/solr/store")
.withGraphStoreProtocolEndpointPath("/rdf-graph-store")
.withSPARQLEndpointPath("/sparql")
.build();
The example above uses all defaults value so in that case you could simply do:
final SolRDF solrdf = SolRDF.newBuilder().build();
In case SolRDF is running in SolrCloud mode, you can provide only the Zookeeper address(es):
SolRDF solrdf = SolRDF.newBuilder()
.withZkHost("192.168.1.132:2181")
.build();
The SolrCloud client is still under development
Once you got a valid SolRDF reference as described above, you can use one of the add(...) methods:
void add(List<Statement> statements)
void add(String uri, List<Statement> statements)
void add(Statement [] statements)
void add(String uri, Statement [] statements)
void add(Statement statement)
void add(String uri, Statement statement)
void add(Resource subject, Property predicate, RDFNode object)
void add(String uri, Resource subject, Property predicate, RDFNode object)
void add(String url, String lang)
void add(String graphUri, String url, String lang)
void add(InputStream stream, String lang)
void add(String graphUri, InputStream stream, String lang)
void add(Reader charStream, String lang)
void add(String graphUri, Reader charStream, String lang)
For example:
solrdf.add(new FileReader("/usr/local/data/mydata.nt", "N-TRIPLES");
A complete list of all available Add scenarios can be found in the test case org.gazzax.labs.solrdf.client.AddTestCase (under the test folder)
Following the same approach for adding data, you can use one of the "query" methods of the SolRDF proxy:
// SELECT
final ResultSet result = solrdf.select("SELECT * WHERE {?s ?p ?o} LIMIT 10");
// CONSTRUCT
final Model result = solrdf.construct("CONSTRUCT ...");
// DESCRIBE
final Model result = solrdf.describe("DESCRIBE ...");
// ASK
final boolean result = solrdf.ask("ASK ...");
1. Introduction
2. User Guide
2.1 Get me up and running
2.2 Add Data
2.3 RDF Mode
2.3.1 SPARQL 1.1 Protocol
2.3.1.1 Query
2.3.1.2 Update
2.3.3 Graph Store Protocol
2.4 Hybrid mode
2.4.1 Querying
2.4.2 Faceted search
2.4.2.1 Fields
2.4.2.2 Objects queries
2.4.2.3 Objects ranges queries
2.5 Deployments
2.6.1 Standalone
2.6.2 SolrCloud
2.6 Message Catalog
3. Developer Guide
3.1 Development Environment
3.2 (Java) Client API
3.3 Solr Configuration
3.3.1 schema.xml
3.3.2 solrconfig.xml
3.4 Components
3.4.1 Stream Loader
3.4.2 Query Parser
3.4.3 Search Component
3.4.4 Facet Component
3.4.5 Response Writer
4. Continuous Integration
5. Roadmap
6. Mailing lists