-->
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.  [ 6 posts ] 
Author Message
 Post subject: [Search]how to index childClass by parentClass's property
PostPosted: Wed Apr 25, 2007 10:14 pm 
Newbie

Joined: Wed Apr 25, 2007 9:58 pm
Posts: 3
These days I did test on Hibernate Search for migration purpose from other qurey approch(HQL,etc.).
I met some questions, can anyone help me?

1.Can I write the Index label in the mapping xml file?
We don't use Annotatio currently.

2.How to make an index for childClass by parentClass's property?
For example:
public class B{
private String id;
Private String Name;

public void setId(String id){
this.id=id;
}

public String getId(){
return this.id;
}
...
}
public class A extends B{
private String code;
...
}


I can easily index A by code, but how to index A by id or name?
Id and name are written in B, I don't want index B.
Can Hibernate Search do it now? How to write the Index label in A?


Of course, if I rewrite the code of id and name defination in A, I can do it, but it's not a good solution.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 25, 2007 11:26 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
To your first question, there is no support for an xml schema.
The infrastructure is there, so if some one want to work on that, I can help him.

To your second question. It will work if you @Indexed both A and B.
you will be able to find As by name.

Now does it make sense to Index A and not B but still want the proeprties of B?
I think it doesn't really make much sense, like HQL, Hibernate Searches are polymorphic by nature. Just embrace that.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 26, 2007 1:38 am 
Newbie

Joined: Wed Apr 25, 2007 9:58 pm
Posts: 3
emmanuel wrote:
To your second question. It will work if you @Indexed both A and B.
you will be able to find As by name.


I really don't know how to write the index label in both of A and B and how to write the search sentense in this case.

If I index A and B like this:

@Indexed(index="B")
public class B{
private String id;
@Field(store=Store.YES,index=Index.TOKENIZED)
public String getId(){
this.id
}
}

@Indexed(index="A")
public class A extends B{
private String name;
@Field(store=Store.YES,index=Index.TOKENIZED)
public String getName(){
this.name
}
}

And the search like this:
QueryParser queryParser=new QueryParser("id",new StandardAnalyzer());
org.apache.lucene.search.Query query=queryParser.parse("id:5*");
Search.createFullTextSession(getSessionFactory().getCurrentSession()).createFullTextQuery(query, A.class).list();


I create two index directories, can Hibernate Search know the relationship of these two indexes?
How to change the code to get the purpose I want? Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 26, 2007 3:08 am 
Newbie

Joined: Wed Apr 25, 2007 9:58 pm
Posts: 3
emmanuel wrote:
To your first question, there is no support for an xml schema.
The infrastructure is there, so if some one want to work on that, I can help him.


Maybe I can help to do part of the work, but I don't know whether I can do it.
Where can I find some documentations to relize this?


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 01, 2007 3:31 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
mayabin wrote:
I create two index directories, can Hibernate Search know the relationship of these two indexes?
How to change the code to get the purpose I want? Thanks!



The data hierarchy is flatenized in the Lucene indexes, so an index is self sufficient.
I guess one could introduce an @IndexedMappedSuperclass annotation but it's will only save you from having a B index directory with pretty much nothing in it. Doesn't seem to be too bothering

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 01, 2007 3:33 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
mayabin wrote:
emmanuel wrote:
To your first question, there is no support for an xml schema.
The infrastructure is there, so if some one want to work on that, I can help him.


Maybe I can help to do part of the work, but I don't know whether I can do it.
Where can I find some documentations to relize this?


There is no doc, but the best shot would be to look at how EJB3OverridenAnnotationReader is written in Hibernate Annotations, it should be very similar to that. The idea is that the OverridenAnnotationReader is aware of the XML schema and can modify what the configuration see (from an annotation point of view)

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.