-->
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: Hibernate Search Faceting
PostPosted: Thu Sep 22, 2011 6:41 am 
Regular
Regular

Joined: Thu Jun 16, 2011 12:03 pm
Posts: 94
Hi all,

I am having a problem with my query builder when I use polymorphism. I have an abstract class and if I try to initialize the QueryBuilder with this abstract class to make the sentence, it does not work.

In this example, BookEntity is the abstract class.

Is there other way to create the facets or I must use the querybuilder to create the facets?

Code:
builder = fullTextSession.getSearchFactory()
             .buildQueryBuilder()
             .forEntity(BookEntity.class).get();

autorityFacetingRequest = builder.facet().name("Autority")
                                               .onField("autorityName.autorityname_untokenized").discrete()
                                               .orderedBy(FacetSortOrder.COUNT_DESC)
                                               .includeZeroCounts(false).createFacetingRequest();


Thanks in advance.


Top
 Profile  
 
 Post subject: Re: Hibernate Search Faceting
PostPosted: Thu Sep 22, 2011 7:49 am 
Hibernate Team
Hibernate Team

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

the code to create the facet it correct. What is your problem with it?


Top
 Profile  
 
 Post subject: Re: Hibernate Search Faceting
PostPosted: Thu Sep 22, 2011 8:06 am 
Regular
Regular

Joined: Thu Jun 16, 2011 12:03 pm
Posts: 94
The problem is that when i try to create the QueryBuilder from an abstract class it does not work...

I have to do it with the child classes and i would like to search for all of the children classes at the same time....

I think that QueryBuilder does not work with polymorphism..

Thanks in advance


Top
 Profile  
 
 Post subject: Re: Hibernate Search Faceting
PostPosted: Fri Sep 23, 2011 4:24 am 
Regular
Regular

Joined: Thu Jun 16, 2011 12:03 pm
Posts: 94
Hi,

As i told you, if I create my QueryBuilder from an abstract class like BookEntity, it does not work and give me this exception:

java.lang.IllegalArgumentException: Entity for which to retrieve the scoped analyzer is not an @Indexed entity: com.cervantesvirtual.entity.BookEntity


I would like to search for my abstract parent class and get all my results.

Thanks in advance.


Top
 Profile  
 
 Post subject: Re: Hibernate Search Faceting
PostPosted: Fri Sep 23, 2011 4:57 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Can you provide you annotated code? Or create a test case?
Generally though, abstract classes are not indexed. Have you tried to have a non abstract base class?

--Hardy


Top
 Profile  
 
 Post subject: Re: Hibernate Search Faceting
PostPosted: Fri Sep 23, 2011 8:08 am 
Regular
Regular

Joined: Thu Jun 16, 2011 12:03 pm
Posts: 94
Hi,

My QueryBuilder code is:

Code:
    this.fullTextSession = Search.getFullTextSession(this.session);
    this.parser = new MultiFieldQueryParser(luceneVersion, campos, fullTextSession.getSearchFactory().getAnalyzer("myCapsFilter"));
                       
    this.query = parser.parse(this.q);

    this.builder = fullTextSession.getSearchFactory().buildQueryBuilder().forEntity(BookEntity.class).get();


If I use @Indexed in my abstract BookEntity class, i get this error:

Entity for which to retrieve the scoped analyzer is not an @Indexed entity: com.cervantesvirtual.entity.BookEntity


Then, If I use @Indexed and change BookEntity to a normal class then everything works fine. But I would like to maintain my parent class as abstract...it would be possible?

In this case i just have in my lucene indexes the parent class. What if i want to search in my child classes directly?

Thanks in advance.


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.