MarkLogic Semantics can be accessed through client-side APIs that provide support for management of triples and graphs, SPARQL and SPARQL Update, and access to the search features of MarkLogic server. The Java Client and Node.js Client source are available on GitHub.
The chapter includes the following sections:
The Java Client API enables you to create client-side Java applications that interact with MarkLogic. Semantics related features include support for graph and triple management, SPARQL Query, SPARQL Update, and Optic queries.
For details, see Working With Semantic Data in the Java Application Developer's Guide and the following interfaces and classes in the com.marklogic.client.semantics
package in the Java Client API Documentation.
The Node.js Client API can be used for CRUD (Create, Read, Update, and Delete) operations on graphs; creating, reading, updating, and deleting triples and graphs. The DatabaseClient.graphs.write
function can be used to create a graph containing triples, the DatabaseClient.graphs.read
function reads from a graph. The DatabaseClient.graphs.remove
function removes a graph. The DatabaseClient.graphs.sparql
function queries semantic data.
See Working With Semantic Data in the Node.js Application Developer's Guide for more details. The Node.js Client source can be found on GitHub at http://github.com/marklogic/node-client-api. For additional operations, see the Node.js Client API Reference.
These operations only work with managed triples contained in a graph. Embedded triples cannot be manipulated using the Node.js Client API.
The Optic API can be used to search and work with semantic triples in both client-side queries and server-side side queries. Optic can be used for triple data client-side queries with the Java Client API and the REST Client API, but not with Node.js. See Optic Java API for Relational Operations in the Java Application Developer's Guide and Retrieving Rows in the REST Application Developer's Guide for more details.
For server-side queries using the Optic API, see Querying Triples with the Optic API for more information. Also, see the op:from-triples or op.fromTriples functions in the Optic API and the Data Access Functions section in the Application Developer's Guide .