Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Christoph Strobl on spring-data-solr
Search
Enterprise Java User Group Austria
September 25, 2013
Technology
210
0
Share
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
180
Spring Framework 5.2 - Core Container Revisited
ejug
0
170
Andreas Caternberg on Jenkins Pipelines
ejug
0
770
Martin Ahrer on Continuous Delivery Infrastructure With Docker
ejug
0
160
Dirk Mahler on Software Analyse mit jQAssistant & Neo4j
ejug
1
300
Christoph Strobl on Spring Data & Hypermedia
ejug
0
150
Stefan Armbruster on Graph Modelling Antipatterns
ejug
1
130
Stefan Armbruster on Introduction into Neo4J
ejug
1
91
Michael Nitschinger on Building a reactive Couchbase driver for the JVM
ejug
0
150
Other Decks in Technology
See All in Technology
音声言語モデル手法に関する発表の紹介
kzinmr
0
150
GitHub Copilot CLI と VS Code Agent Mode の使い分け
tomokusaba
0
120
The 7 pitfalls of AI
ufried
0
150
コミュニティ・勉強会を作るのは目的じゃない
ohmori_yusuke
0
280
アクセシビリティはすべての人のもの
tomokusaba
0
190
20260428_Product Management Summit_tadokoroyoshiro
tadokoro_yoshiro
15
17k
AndroidアプリとCopilot Studioの統合
nakasho
0
190
社内エンジニア勉強会の醍醐味と苦しみ/tamadev
nishiuma
0
270
Pure Intonation on Browser: Building a Sequencer with Ruby
nagachika
0
390
独断と偏見で試してみる、 シングル or マルチエージェント どっちがいいの?
shichijoyuhi
1
220
ブラウザの投機的読み込みと投機ルールAPIを理解し、Webサービスのパフォーマンスを最適化する
shuta13
1
210
プラットフォームエンジニアリングの実践 - AWS コンテナサービスで構築する社内プラットフォーム / AWS Containers Platform Meetup #1
literalice
1
230
Featured
See All Featured
The Limits of Empathy - UXLibs8
cassininazir
1
320
Context Engineering - Making Every Token Count
addyosmani
9
850
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
120
Unsuck your backbone
ammeep
672
58k
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
160
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
390
Thoughts on Productivity
jonyablonski
76
5.1k
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
160
AI Search: Where Are We & What Can We Do About It?
aleyda
0
7.4k
Paper Plane (Part 1)
katiecoart
PRO
0
6.9k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.7k
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.2k
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!