Emmanuel Bernard

+ Follow
since Oct 22, 2008
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Emmanuel Bernard

Congratulations all.
It was fun to answer all the questions. Hope we converted a few souls to Hibernate Search
Congratulations all.
It was fun to answer all the questions. Hope we converted a few souls to Hibernate Search
Yes paginations are supported and with your favorite (Hibernate Core) APIs

Query query = //create my fullTextQuery
List results = query.list();

Paul's link has more infos.
We have spend a *lot* of time to write this book. I am glad you like the content
Hibernate Search in Action is about Hibernate Search the project, not Hibernate Core.

The book covers all you need to integrate Hibernate Search into your application and build a search engine, including:
- getting started guide
- mapping
- how to query in Hibernate Search
- how to build a Full-text query and what are the different kind of queries available
- how to use declarative filters
- how to optimize Hibernate searches and indexing
- how to access Lucene natively with Hibernate Search
- Lucene scoring and relevance algorithm
- some useful tools from Lucene

Every concept is explained with practical examples. All examples are based on a DVD Store search engine.

You can read the book chapter "road map" on the manning side http://www.manning.com/bernard/excerpt_about.html
for more information.

Hope that helps
Yes this is totally possible.
Your custom bridge will read and part the XML and put the attributes you want into the Lucene Document under the Fields you want.

Typically you will ahve something like that

public class Trade {
@Id @DocumentId Integer orderId;

byte[] orderXml;

OrderXMLIndexer will manipulate the Lucene Document and add fields to it:
- orderXml.brokerName
- orderXml.customerName
- ...

Note that the field name is customizable, Particularly, you do not have to prefix them by the property name (orderXml) though it is recommended.

Your Lucene query will look like
The database and the Lucene index are kept synchronized by Hibernate Search. Every time the database changes via Hibernate Core, the index is updated as well.
Yes you can search numbers and range of numbers.
The catch is to store them in a way to make numeric comparison equivalent to String comparison

2 < 12 but "2" > "12"

The idea is to put non significant zeros
"002" < "012"

You can do that with a custom bridge. There are examples of that (of various flexibility) in chapter 4.
A full-text search is all about searching strings but you can often find a string representation for a datab structure that makes sense for example date in absolute format.

Hibernate Search does support amost java types form the JDK and lets you write custom bridges to convert a structure into a string representation indxed into Lucene. chatper 4 covers Bridges.

A few examples:
- reads a byte[] representing the PDF, extract the text and index it
- read a MS Word file from a URL, extract the text and index it
- take a Map and store it in a way that makes search easier for you
Check the Hibernate tools, they have exactly what you are asking for. They can read a database schema and build the domain model (annotated or using hbm.xml).

JBoss Tools wraps that up in an eclipse plugin
In practice, most of the time the Lucene index structure is store in a file system directory as opposed to the database.
The closest framework is probably Compass but the emphasis is different (check one of the post from yesterday, we discussed that).

That said, annotations have a huge downside -- configuration via annotation requires rebuilding the code should something change. Properly written XML configuration should only require a restart of the application to take effect.

I don't think this argument stands for Hibernate Search
When you change an indexing mapping (say a property or an entity), in 99% of the case you will change some code to build a better query or a different use case. So you will recompile.
As John said, Hibernate Search is quite general. I have seen it used in a lot of problems. Some of the common ones:
- search engine for e-commerce sites
- search engine for backend applications (admin, call center etc)
- used to save loads on the regular RDBMS database (either by replacing the query or by splitting the query into a full-text part and a relational part (and do an intersect)

Another cool thing that is poping up is the ability to full-text search objects in a JBoss Cache. Search for JBoss Cache Searchable. Basically hibernate Search is now independent of Hibernate and can index pretty much anything and listen to any event