Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 2 Agenda 1999 2004 2010 2014
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ The Thing with Search § Simple Requirement spring data
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 6 The Thing with Search § Simple Requirement § Complex Solution
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 7 The Thing with Search § Simple Requirement § Complex Solution § Abstraction { fuzzy : { text : "sprung" } }
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 8 The Thing with Search “…you need to understand at least one level of abstraction beneath the one at which you're working. ! Neal Ford
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ The Goal… “…provide a familiar and consistent Spring based programming model retaining store specific features and capabilities” (O.Gierke) 10
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Spring Data Modules 11 Commons Neo4j Gemfire JPA Solr ElasticSearch REST Cassandra Couchbase Redis MongoDB Community modules Core modules Aerospike Hazelcast Crate Incubating
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 14 Spring Data § Low level Templates template.execute(new DbCallback<CommandResult>() { @Override public CommandResult doInDB(DB db) { return db.command(new BasicDBObject("profile", 2)); } });
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 15 Spring Data § Low level Templates § Repositories interface BlogPostRepo extends CrudRepository<BlogPost, String> {} repository.save(blogPost); repository.findAll(); repository.findOne("SpringIO-‐2015"); repository.delete(blogPost);
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 18 Spring Boot …lets you pair program with the Spring team. Josh Long source: https://twitter.com/rob_winch/status/364871658483351552
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 19 Spring Boot Keeps you focused Minimal ramp up time Batteries included Gets out of the way quickly Only for prototyping Just an embedded container Beginners only Bad experience
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 20 $text $search your Documents Spring Data
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 21 Spring Data MongoDB - Text Index § Text Index db.collection.ensureIndex( { title : "text", content : "text", categories : "text"} ) , { weights : { title : 3, content : 2 } }
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 22 Spring Data MongoDB - Text Index § Text Index § Manual Index Creation TextIndexDefinition textIndex = new TextIndexDefinitionBuilder() ! ! ! ! .onField("title", 3F) .onField("content", 2F) .onField("categories") .build(); operations.indexOps(BlogPost.class).ensureIndex(textIndex);
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 23 Spring Data MongoDB - Text Index § Text Index § Manual Index Creation § Automatic Index Creation @Document class BlogPost { @Id String id; @TextIndexed(weight = 3) String title; @TextIndexed(weight = 2) String content; @TextIndexed List<String> categories;
Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Spring Data MongoDB
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 31 Spring Data Solr § Query Time Boosting ! List<Product> findTop10ByNameOrDescription(@Boost(2) String name, String description); @Document class Product { @Id String id; //... @Score Float score;
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 32 Spring Data Solr § Query Time Boosting § Result Highlighting @Highlight(fragsize = 20, snipplets = 3) HighlightPage<Product> findByDescription(String description, Pageable page);
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 33 Spring Data Solr § Query Time Boosting § Result Highlighting § Schema API class Product { @Id String id; @Indexed(type = "text_general") String name; @Indexed(name = "cat", type = "string") List<String> category; @Indexed boolean inStock; }
Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Spring Data Solr
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 36 Spring Data Elasticsearch § Indexing @Document(indexName = "publications", type = "article", shards = 1, ... class Article { @Id String id; ! @Document(indexName = "publications", type = "book", shards = 1, ... class Book { @Id String id;
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 38 Spring Data Elasticsearch § Indexing § Type Mapping § Search API CriteriaQuey cq = new CriteriaQuery(where("location").within(… ! SearchQuery sq = new NativeSearchQueryBuilder().withQuery(matchAllQuery()) .withFilter(boolFilter().must(termFilter("id", documentId))).build();
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 39 Spring Data Elasticsearch § Facets SearchQuery query = new NativeSearchQueryBuilder() .withQuery(matchAllQuery()) .withFacet(new TermFacetRequestBuilder("categoriesFacet") .allTerms() .fields("categories") .descCount()); FacetPage<Article> page = template.queryForPage(query, Article.class);
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 40 Spring Data Elasticsearch § Facets § Aggregation SearchQuery query = new NativeSearchQueryBuilder() .withQuery(matchAllQuery()) .withSearchType(SearchType.COUNT) .withTypes("article") .addAggregation(terms("subjects").field("subject")) .build() Aggregations aggregations = template.queryForPage(query, response -‐> response.getAggregations());
Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Spring Data Elasticsearch
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ More Boot, Spring Data, MongoDB, Neo4j, Elasticsearch…. TODAY § 15:00 Master Spring Boot auto-configuration (Stéphane Nicoll) § 16:30 Spring Boot is made for tooling (Yann Cébron & Stéphane Nicoll) ! TOMORROW § 10:00 MongoDB and Spring – Two leaves of a same tree (Norberto Leite) § 11:30 Spring Data REST – Repositories meet hypermedia (Oliver Gierke) § 12:30 Building High Performance Applications with Spring Data Neo4j 4.0 (Michael Hunger & Vince Bickers) § 14:30 Workshop Building “Bootiful” Microservices with Spring Cloud (Josh Long) § 15:30 Scaling real time search and analytics with Elasticsearch (Clinton Gormley) 43
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 44 Learn More. Stay Connected. Twitter: twitter.com/springcentral YouTube: spring.io/video LinkedIn: spring.io/linkedin Google Plus: spring.io/gplus