Integrating Solr in JEE Applications. Chris Male Apache Solr / Lucene Committer /

Similar documents
Do JSON. Jackson. with. By Baeldung

Search Evolution von Lucene zu Solr und ElasticSearch. Florian

Java EE Application Assembly & Deployment Packaging Applications, Java EE modules. Model View Controller (MVC)2 Architecture & Packaging EJB Module

Shallow Copy vs. Deep Copy

ElasticSearch in Production

COMP 430 Intro. to Database Systems. SQL from application code

Spring Framework. Christoph Pickl

purequery Deep Dive Part 2: Data Access Development Dan Galvin Galvin Consulting, Inc.

An Application for Monitoring Solr

Parallel SQL and Streaming Expressions in Apache Solr 6. Shalin Shekhar Lucidworks Inc.

Distributed Programming and Remote Procedure Calls (RPC): Apache Thrift. George Porter CSE 124 February 19, 2015

EPL660: Information Retrieval and Search Engines Lab 3

Sitesbay.com. A Perfect Place for All Tutorials Resources. Java Projects C C++ DS Interview Questions JavaScript

Improving Drupal search experience with Apache Solr and Elasticsearch

Red Hat JBoss Data Grid 7.1 Migration Guide

Java J Course Outline

Tutorial 4 Data Persistence in Java

Red Hat JBoss Data Grid 7.0

POJOs to the rescue. Easier and faster development with POJOs and lightweight frameworks

2005, Cornell University

Distributed Systems Recitation 1. Tamim Jabban

Ch 7 Designing Java Classes & Class structure. Methods: constructors, getters, setters, other e.g. getfirstname(), setfirstname(), equals()

Spring Persistence. with Hibernate PAUL TEPPER FISHER BRIAN D. MURPHY

Soir 1.4 Enterprise Search Server

JVA-117A. Spring-MVC Web Applications

X-components 3.1. User manual. Jindřich Kocman, Václav Trojan. Version: 3.1 Date:

TDDD05: Application frameworks

Struts: Struts 1.x. Introduction. Enterprise Application

Classes and Objects 3/28/2017. How can multiple methods within a Java class read and write the same variable?

Ch 7 Designing Java Classes & Class structure. Fields have data values define/describe an instance

2/26/2017. DataFrame. The input data can be queried by using

Dali Java Persistence Tools

Perform Database Actions Using Java 8 Stream Syntax Instead of SQL. Emil Forslund Java Developer Speedment, Inc.

Database Application Architectures

Programming Web Services in Java

MongoDB Web Architecture

Improving Application Design

Distributed Systems Recitation 1. Tamim Jabban

Week 5-1: ADT Design

Copyright Descriptor Systems, Course materials may not be reproduced in whole or in part without prior written consent of Joel Barnum

HIBERNATE MOCK TEST HIBERNATE MOCK TEST I

PART 1. Eclipse IDE Tutorial. 1. What is Eclipse? Eclipse Java IDE

Implementing a Numerical Data Access Service

Search Engines and Time Series Databases

Jaxb Validate Xml Against Multiple Xsd

Programming Language Concepts Object-Oriented Programming. Janyl Jumadinova 28 February, 2017

CO Java EE 7: Back-End Server Application Development

Getter and Setter Methods

Fast Track to Spring 3 and Spring MVC / Web Flow

Chapter 13. Hibernate with Spring

Ch 7 Designing Java Classes & Class structure

Migrating traditional Java EE applications to mobile

Unit Tes2ng Ac2vity. SWEN-261 Introduc2on to So3ware Engineering. Department of So3ware Engineering Rochester Ins2tute of Technology

JVA-117E. Developing RESTful Services with Spring


Java Server Page (JSP)

SOCIAL NETWORKING USING WEB SERVICES VIJAY CHAKRAVARAM. B.Tech, Jawaharlal Nehru Technological University, India, 2013 A REPORT

Java Object Oriented Design. CSC207 Fall 2014

Once VS2015 is configured to build C# projects, create a new Visual C#, ASP.NET Web application. Select Web Forms

ECE 122. Engineering Problem Solving with Java

Page 1

com Spring + Spring-MVC + Spring-Boot + Design Pattern + XML + JMS Hibernate + Struts + Web Services = 8000/-

CmSc 150 Fundamentals of Computing I. Lesson 28: Introduction to Classes and Objects in Java. 1. Classes and Objects

CS 2340 Objects and Design - Scala

CMPSCI 187: Programming With Data Structures. Lecture 6: The StringLog ADT David Mix Barrington 17 September 2012

Spring Framework 2.0 New Persistence Features. Thomas Risberg

Cloning Enums. Cloning and Enums BIU OOP

Software and Programming 1

Copyright Descriptor Systems, Course materials may not be reproduced in whole or in part without prior written consent of Joel Barnum

Introduction to the Spring Framework

Overview of Eclipse Lectures. Module Road Map

Pro JPA 2. Mastering the Java Persistence API. Apress* Mike Keith and Merrick Schnicariol

Java SE7 Fundamentals

Leverage Rational Application Developer v8 to develop Java EE6 application and test with WebSphere Application Server v8

Week. Lecture Topic day (including assignment/test) 1 st 1 st Introduction to Module 1 st. Practical

Teach your (micro)services speak Protocol Buffers with grpc.

Extracts from Intro to Db - Jdbc - JPA SpringData

JAX-RS. Sam Guinea

COURSE DETAILS: CORE AND ADVANCE JAVA Core Java

CIS 110: Introduction to Computer Programming

Application Development in JAVA. Data Types, Variable, Comments & Operators. Part I: Core Java (J2SE) Getting Started

Outline. CIS 110: Introduction to Computer Programming. Any questions? My life story. A horrible incident. The awful truth

Search and Time Series Databases

Kotlin In Spreadshirt JavaLand,

Packaging Data for the Web

RPC flow. 4.3 Remote procedure calls IDL. RPC components. Procedure. Program. sum (j,k) int j,k; {return j+k;} i = sum (3,7); Local procedure call

Data Presentation and Markup Languages

API Documentation. Web Application Development. Zsolt Tóth. University of Miskolc. Zsolt Tóth (University of Miskolc) API Documentation / 28

Inheritance and Polymorphism

Generating/Updating code from whole project

/ / JAVA TRAINING

CO Java SE 8: Fundamentals

Introduction to JPA. Fabio Falcinelli

Teneo: Integrating EMF & EclipseLink

Realtime visitor analysis with Couchbase and Elasticsearch

Introduction to Spring Framework: Hibernate, Spring MVC & REST

Lecture 3. COMP1006/1406 (the Java course) Summer M. Jason Hinek Carleton University

Classes. Classes as Code Libraries. Classes as Data Structures. Classes/Objects/Interfaces (Savitch, Various Chapters)

Introduction to Web Application Development Using JEE, Frameworks, Web Services and AJAX

Creating an Avro to Relational Data Processor Transformation

Transcription:

Integrating Solr in JEE Applications Chris Male Apache Solr / Lucene Committer chris@jteam.nl / chrism@apache.org

Agenda SolrJ in Action Lessons from Databases Typed Schemas Typed Queries / Responses Document Binding

JEE Application Needs Clean interfaces Layering and abstractions Dependency Injection Readable, Extensible, Maintainable Testable Limited client API exposure

SolrJ in Action Official Java client for Solr Uses Binary protocol HTTP vs Embedded General, all purpose API Some ORM-like binding Can handle custom requests, response Roll your own if really custom

SolrJ in Action Example <bean id= solrserver class= org.apache.solr.client.solrj.impl.commonshttpsolrserver > </bean> <constructor-arg index= 0 value= ${solr.server /> <bean id= searchservice class= de.berlinbuzzwords.example.defaultsearchservice > </bean> <property name= solrserver ref= solrserver />

SolrJ in Action Example SolrInputDocument document = new SolrInputDocument(); document.addfield( first_name, Chris ); document.addfield( last_name, Male ); document.addfield( age, 26); solrserver.add(document); solrserver.commit(); SolrQuery query = new SolrQuery( last_name:male ); QueryResponse response = solrserver.query(query); assertequals(1, response.getresults().numfound);

SolrJ in Action Analysis Efficient, easy to use Standard Solutions are usually best Untyped, String crazy Doesn't speak domain's language Searching for people vs Searching for cars Implementation detail Room for improvement

Lessons from Databases Database Drivers: Efficient protocols like Solr's Binary Protocol JDBC Standard API General, easy to use, String crazy Like SolrJ DAOs, Repositories Domain model in driver seat Typed queries, results Refactor friendly Less error-prone Speaks domain language Testable

Lessons from Databases

Typed Schemas Introduce Field construct Encode Solr Schema as Enum of Fields Field names stored as String once Application uses Enum Refactor friendly Uses domain language, not Solr language FIRST_NAME vs first_name_text

Typed Schemas Example public interface Field { String getname(); // other properties public enum PeopleSchema implements Field { FIRST_NAME( first_name ), LAST_NAME( last_name ), AGE( age ); String name; PeopleSchema(String name) { this.name = name; String getname() { return name;

Typed Queries Reduce SolrJ usage Domain specific Queries PeopleQuery vs CarQuery vs EventQuery Use domain language withfirstname, withcolour, startingat Use Typed Schema Convert to SolrQuery at execution time execute(solrserver) Hierarchy for common functionality Field based Query, FilterQuery, Facet etc

Typed Queries Example public class PeopleQuery extends AbstractSearchQuery { public PeopleQuery(String firstname) { setquery(peopleschema.first_name, firstname); public PeopleQuery withlastname(string lastname) { addfilterquery(peopleschema.last_name, lastname); return this; public PeopleQuery betweenage(int lowerage, int upperage) { addrangequery(peopleschema.age, lowerage, upperage); return this; public??? execute(solrserver solrserver) { QueryResponse queryresponse = solrserver.execute(convert()); return new???(queryresponse);

Typed Queries Example PeopleQuery peoplequery = new PeopleQuery( Chris ).withlastname( Male ).betweenage(25, 27);??? response = peoplequery.execute(solrserver);

Typed Responses Responses from Queries should also be typed QueryResponse is bad! Features based on Field Facets per Field, Highlighting per Field Page of results List of Results Current page, page size, total results Parsed after execution Need to map field names back to Enum public static Field findfield(string fieldname) { ;

Typed Responses Example public class PeopleResult extends AbstractSearchResult<People> { public PeopleResult(QueryResponse response) { parse(response); public FacetResult getagefacet() { return getfacetresult(peopleschema.age); public String getsuggestedname() { return suggestion; public Page<People> getresults() { // borrowed from superclass return page;

Document Binding Marshalling / unmarshalling Domain model SolrJ provides simple support: DocumentObjectBinder @Field( fieldname ) addbean(object bean), List<T> getbeans(class<t> beantype) Cannot use Typed Schema Java limitation String field names used again Cannot handle embedded objects Needs ALOT of work

Document Binding Example public class People { @Field( first_name ) private String firstname; @Field( last_name ) private String lastname; @Field( age ) private int age; // getters & setters

Not Just Solr Typed searching not just for Solr Lucene, Elastic Search, NoSQL even Facets, highlighting, spell checking are common Reduce client library exposure Abstract SearchServer wrapper

Conclusion SolrJ standard client library Database experiences should be heeded Typed Queries & Results improve readbility, maintainability Document binding needs improvements Applicable to all search solutions chris@jteam.nl http://www.jteam.nl