A Java Developer s Guide to Building Applications with MarkLogic Justin Makeig, Director Product Management, MarkLogic Erik Hennum, Lead Engineer, MarkLogic MarkLogic World, April 2014
Hello, my name is Product Manager for 6+ years at MarkLogic Background in consulting and web development Passionate about data, apps, and user experience Hello, my name is Lead Engineer at MarkLogic, formerly IBM and Informix Focus on application interfaces in Java, REST, and XQuery Background in XML, RDF, and JSON technologies SLIDE: 2
Agenda MarkLogic Java Reference architectures API landscape (Re)-Introducing the Java Client API Document CRUD, search, analytics Extensibility What s on the roadmap? SLIDE: 3
SLIDE: 4
Why MarkLogic matters to Java developers Document-oriented schema when you need it? Indexes: Values, text, geo, semantics, alerting Real-time, always consistent Proven and trusted in production SLIDE: 5
User Interface Data views, user workflow Middleware Business rules, domain model, integration Database Security, Config Mgmt Business Services Resources (Customer, Approval, etc.) JSON over HTTP Data Services Documents JSON/XML over HTTP Persistent state, stored procedures SLIDE: 6
Spectrum of Java interfaces XCC Custom HTTP Services Extensions Java Client API Flexibility Connector for Hadoop Productivity SLIDE: 7
Application Application Logic Java Client API Extensions HTTP MarkLogic REST API Search, CRUD, Alerting, Extensions SLIDE: 8 User code Framework code
(RE)-INTRODUCING THE JAVA CLIENT API SLIDE: 9 COPYRIGHT 2013 MARKLOGIC CORPORATION. ALL RIGHTS RESERVED.
Lifecycle: create, use, release DatabaseClient dbc = DatabaseClientFactory.newClient(...); pool of persistent connections to the REST server QueryManager qrymgr=dbc.newquerymanager(); managers are thread-safe after initialization dbc.release(); keep client until done working with the database SLIDE: 10
Document CRUD document uri, content, and metadata (collections, permissions, quality) format binary, JSON, text, or XML content IO handle extensible adapters for byte[ ], DOM, File, InputStream, JAXB, String,... services read / write / delete, transform on read or write, patch in place, optimistic locking, multi-statement transactions,... SLIDE: 11
Searching documents Structured Query Builder sqb.value( sqb.element("city"), "Chicago" ) Query by Example String with Options Snippets and Metadata Facets Alerting querymgr.newrawquerybyexampledefinition( "{\"$query\": {\"city\": \"Chicago\"} }" ) querymgr.newstringdefinition("myoptions").withcriteria("city:chicago") Highlight text matches inside the document content, extract fragments Count the documents with values from an enumeration or with dates or numbers within range buckets Check which queries match a document (subcriptions) SLIDE: 12
Analytics Values: aggregate or page over a range index avg, count, max, median, min, rank, stddev, sum, variance, UDF (User Defined Function) Tuples: co-occurrence of range index values in documents correlation, covariance, UDF SLIDE: 13
Extensibility Types of extensions Document / search transforms XSLT, XQuery Search API hooks custom parsing, snippets Resource services anything XQuery can do Supporting modules Process Install extension on the server SLIDE: 14 Write Java interface for resource service like RMI
Installing and calling resource services Java client Application source file Java API install MarkLogic server REST API class Resource Manager delete, get, post, put XQuery services SLIDE: 15
Open Development Always Apache 2.0 license Master branch (and tests!) moved to GitHub Incremental development in the open Public issue tracking and RFEs (Eventually) pull requests https://github.com/marklogic/java-client-api SLIDE: 16
Application Application Logic Java Client API Extensions HTTP MarkLogic REST API Search, CRUD, Alerting, Extensions SLIDE: 17