-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 
Author Message
 Post subject: First step indexing XML column
PostPosted: Tue Sep 21, 2010 5:19 am 
Newbie

Joined: Fri Mar 03, 2006 6:16 am
Posts: 6
Hi,
I have the column definition like:
Code:
   @Lob
   @Basic(fetch = FetchType.LAZY)
   @Column(nullable = false, columnDefinition = "XML")

There is no documentation about indexing complex types like "XML" with hibernate search framework. What would be the first steps for this? Defining custom Analyzer?


thanks.


Top
 Profile  
 
 Post subject: Re: First step indexing XML column
PostPosted: Tue Sep 21, 2010 6:13 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi,

if you want to index xml you will need indeed a custom analyzer. Somehow you have to extract the values to be indexed from the xml.


Top
 Profile  
 
 Post subject: Re: First step indexing XML column
PostPosted: Tue Sep 21, 2010 9:30 am 
Newbie

Joined: Fri Mar 03, 2006 6:16 am
Posts: 6
Thank you for the instant response,

There is any XML analyzer already which I could use as starting point? or I should write it from the scratch. It would be very helpful if you can point out some documentation or at least some very basics steps.


Top
 Profile  
 
 Post subject: Re: First step indexing XML column
PostPosted: Tue Sep 21, 2010 9:44 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
I am not aware of a "standard" xml analyzer. There are so many different libraries and ways to parse and extract the text from an xml document that it is hard to recommend a "best" approach. You could for example use SAX to parse the document.

--Hardy


Top
 Profile  
 
 Post subject: Re: First step indexing XML column
PostPosted: Fri Sep 24, 2010 9:56 am 
Newbie

Joined: Fri Mar 03, 2006 6:16 am
Posts: 6
Hi Hardy,

I'm using JAXB for my XML files/objects so marshall/unmarshall is not a problem. But I would like to create new lucene fields based on unmarshalled xml file, unfortunately in the Analyzer I see only plain string token.
There is any other approach for this instead of using analyzer? Or How can I add custom fields from Analyzer.
In the end if I will have some xml like:
Code:
<doc>
<field name="age">65</field>
</doc>


I would like to find it by using lucene search query like:
Code:
age:[60 TO 70]


So for this I will need to create from xml the new Field named age with value 65.
Please correct me if I'm wrong.




thanks for your help,
Dima


Top
 Profile  
 
 Post subject: Re: First step indexing XML column
PostPosted: Mon Sep 27, 2010 6:35 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
kirpi4ik wrote:
There is any other approach for this instead of using analyzer? Or How can I add custom fields from Analyzer.
In the end if I will have some xml like:
Code:
<doc>
<field name="age">65</field>
</doc>


I would like to find it by using lucene search query like:
Code:
age:[60 TO 70]


An alternative approach would be a custom field bridge (check the Search online documentation). Provided the xml string is stored in a String property within an indexed class, you could annotate the property with @Field and @FieldBridge. I your bridge implementation you would then use JAXB to parse the xml and extract the key value pairs you want to add to the index.

--Hardy


Top
 Profile  
 
 Post subject: Re: First step indexing XML column
PostPosted: Mon Sep 27, 2010 7:25 am 
Newbie

Joined: Fri Mar 03, 2006 6:16 am
Posts: 6
Hi Hardy,

This "FieldBridge" seems to be exactly what I need, thank you very much.


with best regards,
Dima


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.