-->
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.  [ 9 posts ] 
Author Message
 Post subject: manytoone relationship and faceting
PostPosted: Thu Sep 01, 2011 4:18 am 
Newbie

Joined: Thu Sep 01, 2011 4:10 am
Posts: 5
does maytoone relation ship work with hibernate search faceting?

I have two entity comany, and companyfacality ,
one campay have have multiple companyfacality , and i want to search based on companyfacality country,

I can see in index that company has multiple companyfacility field using luke, but when i try to do facating on that field it only conside one of that field,

Does any one have idea what coude be wrong?


Top
 Profile  
 
 Post subject: Re: manytoone relationship and faceting
PostPosted: Thu Sep 01, 2011 8:40 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hi,
I'm not sure I understand, could you please create a *minimal* unit test?
thanks

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject: Re: manytoone relationship and faceting
PostPosted: Sat Sep 03, 2011 2:28 pm 
Newbie

Joined: Thu Sep 01, 2011 4:10 am
Posts: 5
i have create minimal test in hibernate search codebase.

You can get file from following link,drop file into corrosponding package and test it.
http://dl.dropbox.com/u/31823287/facet_test.zip

Let me know if problem i am facing is still not clear.


Top
 Profile  
 
 Post subject: Re: manytoone relationship and faceting
PostPosted: Sat Sep 03, 2011 3:36 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hi, thank you for the example.
There are two errors in your code:

1) The "country" string should not be annotated as @IndexedEmbedded, but as @Field

Code:
   private int id;
   @ContainedIn
   @ManyToOne(fetch = FetchType.LAZY)
   @JoinColumn(name = "companyId", nullable = false)
   private Company company;
   @IndexedEmbedded // Make this @Field instead
   private String country;
   


2) you forgot to add the facilities to the set of facilities of the company
The CompanyFacility constructors should be:

Code:
   
   public Companyfacility() {
   }
   
   public Companyfacility(Company company,String country) {
      this.company = company;
      this.country = country;
      company.getCompanyfacilities().add( this );
   }


When dealing with relations in Hibernate, always make sure you update both directions of the relation:
Companyfacility.company
AND
Company.companyfacilities

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject: Re: manytoone relationship and faceting
PostPosted: Sat Sep 03, 2011 10:14 pm 
Newbie

Joined: Thu Sep 01, 2011 4:10 am
Posts: 5
Thanks Sanne,

Both of my point solve my problem.


Top
 Profile  
 
 Post subject: Re: manytoone relationship and faceting
PostPosted: Sun Sep 04, 2011 4:19 am 
Newbie

Joined: Thu Sep 01, 2011 4:10 am
Posts: 5
Hi Sanne,

Thanks for reply,
Although it is giving correct facet item but facet count are still wrong, Can you take a look at it again?

I have update code with your suggestion and added count related test in minimal test case.
http://dl.dropbox.com/u/31823287/facet_test.zip


Top
 Profile  
 
 Post subject: Re: manytoone relationship and faceting
PostPosted: Sun Sep 04, 2011 2:56 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hi,
your code looks like correct now, so I think this is a bug with the Faceting implementation.
Could you please open a JIRA issue and attach your unit tests there?

thanks

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject: Re: manytoone relationship and faceting
PostPosted: Mon Sep 05, 2011 12:14 am 
Newbie

Joined: Thu Sep 01, 2011 4:10 am
Posts: 5
Thanks for reply,

I have opened jira issue , HSEARCH-900

-pragnesh


Top
 Profile  
 
 Post subject: Re: manytoone relationship and faceting
PostPosted: Mon Sep 05, 2011 10:47 am 
Beginner
Beginner

Joined: Mon Apr 11, 2011 7:56 am
Posts: 38
Probably related to Lucene's field cache only compatible with single valued fields. See also: viewtopic.php?f=9&t=1010472 (HSEARCH-726)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 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.