This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes Hibernate Search in Action - application of 'Fieldable' lazy field Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate Search in Action - application of Watch "Hibernate Search in Action - application of New topic
Author

Hibernate Search in Action - application of 'Fieldable' lazy field

Dinesh Sundrani
Ranch Hand

Joined: Mar 21, 2006
Posts: 78
So I have a trade order execution system where the stock order once executed and confirmed, the complete order.xml is stored in an Oracle DB as a BLOB field. Now I have 2 fields which I need to index and search on: 1. The OrderId numeric field and the BLOB order.xml field.

Does Hibernate Search custom field bridge and a Lucene Fieldable lazy field implementation help in such a case to read the xml tags, extract the CDATA text and index on those words so as to become easier to be searchable by Broker Name, Customer Name, CUSIP Id, Stock Ticker, etc�
Emmanuel Bernard
author
Ranch Hand

Joined: Oct 22, 2008
Posts: 62
Hi
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;

@Field(bridge=@FieldBridge(impl=OrderXMLIndexer.class)
@Lob
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
"orderXml.brokerName:Merril"
Dinesh Sundrani
Ranch Hand

Joined: Mar 21, 2006
Posts: 78
Bingoooo !!! That's really what I was looking for..

"orderXML.brokerName:MER"
"orderXML.brokerName:LEH"
"orderXML.brokerName:GS"
"orderXML.protfolioName:JeffersonCharitableTrust"
"orderXML.sellRecommendation:BUY"
"orderXML.ratingAgency:Fitch"


 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Hibernate Search in Action - application of 'Fieldable' lazy field