Hibernate Search 5: Adding Full-Text Query Super-Powers to Your JPA!
Hibernate Search Seam
-
Upload
prasoon-kumar -
Category
Documents
-
view
220 -
download
0
Transcript of Hibernate Search Seam
-
8/6/2019 Hibernate Search Seam
1/20
Copyright Red Hat 2007-2009
Hibernate SearchGoogling your persistence domain model
Emmanuel BernardDoer
JBoss, a division of Red Hat
Monday, April 20, 2009
-
8/6/2019 Hibernate Search Seam
2/20
Copyright Red Hat 2007-2009
Search: left overof todays applications
Add search dimension to the domain model
2
Frankly, search sucks on this project
-- Anonymous boss
Why? How to fix that? For cheap?
Monday, April 20, 2009
-
8/6/2019 Hibernate Search Seam
3/20
Copyright Red Hat 2007-2009
Integrate full-text search andpersistent domain
SQL Search vs Full-text Search
Object model / Full-text Search mismatches
Demo
Hibernate Search architecture
Configuration and Mapping
Full-text based object queriesSome more features
3
Monday, April 20, 2009
-
8/6/2019 Hibernate Search Seam
4/20
Copyright Red Hat 2007-2009
SQL search limits
Wildcard / word search
%hibernate%
Approximation (or synonym)hybernat
Proximity
Java close to PersistenceRelevance or (result scoring)
multi-column search
4
Monday, April 20, 2009
-
8/6/2019 Hibernate Search Seam
5/20
Copyright Red Hat 2007-2009
Full Text Search
Search information
by word
inverted indices (word frequency, position)
In RDBMS engines
portability (proprietary add-on on top of SQL)
flexibility
Standalone engine
Apache Lucene(tm) http://lucene.apache.org
5
Monday, April 20, 2009
http://lucene.apache.org/http://lucene.apache.org/http://lucene.apache.org/ -
8/6/2019 Hibernate Search Seam
6/20
Copyright Red Hat 2007-2009
Mismatches with a domain model
Structural mismatch
full text index are text only
no reference/association between documentSynchronization mismatch
keeping index and database up to date
Retrieval mismatch
the index does not store objects
certainly not managed objects
6
ApplFwk
Persistence
Search
Domain
Model
Monday, April 20, 2009
-
8/6/2019 Hibernate Search Seam
7/20
Copyright Red Hat 2007-2009 7
DemoLets google our application!
Monday, April 20, 2009
-
8/6/2019 Hibernate Search Seam
8/20
Copyright Red Hat 2007-2009
Hibernate Search
Under the Hibernate platform
LGPL
Built on top of Hibernate CoreUse Apache Lucene(tm) under the hood
In top 10 downloaded at Apache
Very powerful but low leveleasy to use it the wrong way
Solve the mismatches
8
ApplFwk
Persiste
nce
DomainModel
Search
JBoss Seam
Monday, April 20, 2009
-
8/6/2019 Hibernate Search Seam
9/20
Copyright Red Hat 2007-2009
Architecture
Transparent indexing through event system (JPA)
PERSIST / UPDATE / DELETE
Convert the object structure into Index structure
Operation batching per transaction
better Lucene performance
ACID-ity
(pluggable scope)
Backend
synchronous / asynchronous mode
Lucene, JMS 9Monday, April 20, 2009
-
8/6/2019 Hibernate Search Seam
10/20
Copyright Red Hat 2007-2009
Architecture (Backend)
Lucene Directory
standalone or symmetric cluster (limited scalability)
immediate visibility
can afect front end runtime
10
Database
Lucene
Directory
(Index)
Hibernate+
Hibernate Search
Search request
Index update
Hibernate+
Hibernate Search
Search requestIndex update
Monday, April 20, 2009
-
8/6/2019 Hibernate Search Seam
11/20
Copyright Red Hat 2007-2009
Architecture (Backend)
JMS (Cluster)
Search processed locally / Change sent to master
asynchronous indexing (delay)
No front end extra cost / good scalability
11
DatabaseHibernate+
Hibernate Search
JMS
queue
Lucene
Directory
(Index)
Master
Hibernate+
Hibernate SearchProcessIndex update
Index update order
Lucene
Directory
(Index)
Copy
Search request
Copy
Slave
Master
Monday, April 20, 2009
-
8/6/2019 Hibernate Search Seam
12/20
Copyright Red Hat 2007-2009
Configuration and Mapping
Configuration
event listener wiring
transparent in Hibernate AnnotationsBackend configuration
Mapping: annotation based
@Indexed
@Field(store, index)
@IndexedEmbedded
@FieldBridge 12Monday, April 20, 2009
-
8/6/2019 Hibernate Search Seam
13/20
Copyright Red Hat 2007-2009
Query
Retrieve objects, not documents
no boilerplate conversion code!
Objects from the Persistence Context
same semantic as a JPA-QL or Criteria query
Use org.hibernate.Query/javax.persistence.Query
common API for all your queries
Query on correlated objects
JOIN-like query "author.address.city:Atlanta"
13
Monday, April 20, 2009
-
8/6/2019 Hibernate Search Seam
14/20
Copyright Red Hat 2007-2009
Query possibilities
bring the best document first
recover from typos
recover from faulty orthography
find from words with the same meaning
find words from the same family
find an exact phrasefind similar documents
14
Monday, April 20, 2009
-
8/6/2019 Hibernate Search Seam
15/20
Copyright Red Hat 2007-2009
More query features
Fine grained fetching strategy
Sort by property rather than relevance
Projection (both field and metadata)metadata: SCORE, ID, BOOST etc
no DB / Persistence Context access
Filterssecurity / temporal data / category
Total number of results
15
Monday, April 20, 2009
-
8/6/2019 Hibernate Search Seam
16/20
Copyright Red Hat 2007-2009
Some more features
Automatic index optimization
Index sharding
Manual indexing and purging
non event-based system
Shared Lucene resources
Native Lucene access
16
Monday, April 20, 2009
-
8/6/2019 Hibernate Search Seam
17/20
Copyright Red Hat 2007-2009
Full-Text search without thehassle
Transparent index synchronization
Automatic Structural conversion through Mapping
No paradigm shift when retrieving data
Clustering capability out of the box
Easier / transparent optimized Lucene use
17
Monday, April 20, 2009
-
8/6/2019 Hibernate Search Seam
18/20
Road Map
Programmatic Mapping API Perf
Multi threaded mass index
Clustering
Query
Dictionary and spellchecker
Easier query buildingMoreLikeThis?
Statistics
18
Monday, April 20, 2009
-
8/6/2019 Hibernate Search Seam
19/20
Copyright Red Hat 2007-2009 19
Q&A
Monday, April 20, 2009
-
8/6/2019 Hibernate Search Seam
20/20
Copyright Red Hat 2007-2009 20
Hibernate Search
http://search.hibernate.org
Hibernate Search in ActionApache Lucene
http://lucene.apache.org
Lucene In Action
http://in.relation.to
http://blog.emmanuelbernard.com
For More Information
Monday, April 20, 2009
http://in.relation.to/http://in.relation.to/http://lucene.apache.org/http://blog.emmanuelbernard.com/http://blog.emmanuelbernard.com/http://in.relation.to/http://in.relation.to/http://lucene.apache.org/http://lucene.apache.org/http://www.hibernate.org/http://www.hibernate.org/