Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Christoph Strobl on spring-data-solr
Search
Enterprise Java User Group Austria
September 25, 2013
Technology
230
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Christoph Strobl on spring-data-solr
Enterprise Java User Group Austria
September 25, 2013
More Decks by Enterprise Java User Group Austria
See All by Enterprise Java User Group Austria
Gerrit Grunwald on What the CRaC... SUPERFAST JVM STARTUP
ejug
2
230
Spring Framework 5.2 - Core Container Revisited
ejug
0
190
Andreas Caternberg on Jenkins Pipelines
ejug
1
830
Martin Ahrer on Continuous Delivery Infrastructure With Docker
ejug
0
180
Dirk Mahler on Software Analyse mit jQAssistant & Neo4j
ejug
1
320
Christoph Strobl on Spring Data & Hypermedia
ejug
0
170
Stefan Armbruster on Graph Modelling Antipatterns
ejug
1
150
Stefan Armbruster on Introduction into Neo4J
ejug
1
120
Michael Nitschinger on Building a reactive Couchbase driver for the JVM
ejug
0
170
Other Decks in Technology
See All in Technology
DWH の限界突破! AI エージェント向け爆速リアルタイムデータ基盤 ClickHouse
jozono
1
470
ブラウザとサーバーから考えるAI時代のフロントエンド監視
shogo4131
3
940
遠藤な_めぐろLT #38 「社内のAI活用推進」@麻布台_20261009
endonanana
0
130
Persisting Massive Data with Rails ~Designing for 60 billion rows, and fighting the bottlenecks~ Railsで挑む大量データ永続化 〜600億件を永続化するための設計とボトルネックとの戦い〜
occhi
0
730
PagerDuty Tech Hub-鳴らすけれど、人は動かない
ezaki
0
170
実践! SRE × AI - ABEMA における AIOps -
tetsuya28
8
3.1k
Running Kotlin + Quarkus with Lambda
nealle
1
3.7k
NDIでApple Vision Proにリアルタイム映像送信
jyouryuusui
0
120
JAWS-UGグッズ職人仕事の流儀
kentapapa
0
100
AIカンパニーへの転換を支えた、エンジニアの仕事の再定義
kworkdev
PRO
2
1.2k
20261017福岡devIO 「AIは"良いダッシュボード"を作れるか?
jtakeda
0
140
Rustuna: Rustによる高速なOptuna実装
pfn
PRO
0
190
Featured
See All Featured
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
310
Measuring & Analyzing Core Web Vitals
bluesmoon
9
1k
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
1
570
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
550
Code Review Best Practice
trishagee
74
20k
Color Theory Basics | Prateek | Gurzu
gurzu
1
490
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
35
2.9k
How to build a perfect <img>
jonoalderson
1
6.1k
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
340
Tell your own story through comics
letsgokoyo
1
1.1k
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
380
Done Done
chrislema
187
17k
Transcript
Spring Data Solr I n t r o d u
c t i o n t o 2013-09-25, Christoph Strobl @eJUG, 48.299707,14.286896
Christoph Strobl Software Engineer Project Lead Spring Data Solr
[email protected]
@stroblchristoph https:/ /github.com/christophstrobl
Apache Solr ...in a hurry...
Apache Solr Enterprise Search Server Built on top of Lucene
Open Interfaces Multiple Collections Clusterable ...
Infrastructure Setup Solr
ZK Infrastructure Setup S1L S1R S2L S2R
ZK Infrastructure Setup S1L S1R S2L S2R
Inside Solr Cores Schema
Solr Schema Types Analysers Fields <fieldType name="string" class="solr.StrField" sortMissingLast="true" />
<fieldType name="lowercase" class="solr.TextField"> <analyzer> <tokenizer class="solr.KeywordTokenizerFactory"/> <filter class="solr.LowerCaseFilterFactory" /> </analyzer> </fieldType> <field name="name_ci" type="lowercase" indexed="true" stored="false"/>
Schemaless since 4.4
Connection HTTP SolrJ q=name:(spring data) AND type:solr&start=0&rows=10 new SolrQuery("name:(spring data)
AND type:solr") .setStart(0).setRows(10);
Solr Query public List<Product> findByNameOrDescription(String name, String description) { String
queryString = "name:" + ClientUtils.escapeQueryChars(name) + " OR description:" + ClientUtils.escapeQueryChars(description); try { SolrQuery query = new SolrQuery(queryString); query.setStart(0).setRows(0); QueryResponse response = solrServer.query(query); long totalValues = response.getResults().getNumFound(); query.setRows(Long.valueOf(totalValues).intValue()); return solrServer.query(query).getBeans(Product.class); } catch (SolrServerException e) { throw ExceptionTranslator.translate(e); } return Collections.emptyList(); }
Spring-Data-Solr
Spring-Data-Solr Spring Data offers serveral APIs around a common SPI
Integration with Apache Solr Community Project with support from pivotal
Connection HTTP SolrJ Spring Data Solr new SimpleQuery(new Criteria("name") .is("spring",
"data").and("type").is("solr") ).setPageRequest(new PageRequest(0, 10)); q=name:(spring data) AND type:solr&start=0&rows=10 new SolrQuery("name:(spring data) AND type:solr") .setStart(0).setRows(10);
Solr Template
SolrTemplate Product product = new Product("foo"); solrTemplate.saveBean(prodcut); solrTemplate.commit(); //... Product
recalled = solrTemplate.queryForObject( new SimpleQuery(new Criteria("id").is("foo")), Product.class); Page<Product> page = solrTemplate.queryForPage( new SimpleQuery(new SimpleStringCriteria("*:*"), Product.class); //... solrTemplate.deleteById("foo"); solrTemplate.commit();
Repository
Repository interface ProductRepository extends SolrCrudRepository<Product, String> { } Product product
= new Product("foo"); repo.save(product) //... Product recalled = repo.findOne("foo"); Page<Product> page = repo.findAll(); //... repo.delete(product);
Derived Queries
Derived Queries interface ProductRepository extends SolrCrudRepository<Product, String> { Page<Product> findByNameStartingWith(String
name, Pageable page); List<Product> findByNameOrDescription(@Boost(2) String name, String description); } Page<Product> page = repo.findByNameStartingWith("fo", new PageRequest(0,10)); List<Product> list = repo.findByNameOrDescription("foo", "foo");
/*Named*/ Queries
/*Named*/ Queries interface ProductRepository extends SolrCrudRepository<Product, String> { @Query("name:?0*") Page<Product>
findByNameStartingWith(String name, Pageable page); @Query(name="findByNameOrDescriptionBoostNameBy2") List<Product> findByNameOrDescription(String name, String description); }
Demo
Custom Repository
Faceting
Highlighting
Custom Types
Questions?
Thank you!