-->
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.  [ 5 posts ] 
Author Message
 Post subject: Hibernate Search IndexedEmbedded
PostPosted: Wed Aug 12, 2009 11:35 am 
Newbie

Joined: Wed Aug 12, 2009 11:17 am
Posts: 3
Hi, there is an Problem.

I have create an Indexed Class like this

Code:
class Holder{
  @IndexedEmbedded
  Set<MyKey> keys = new HashSet<MyKey>();
}


the Key is something like this:
Code:
class MyKey{
  public MyKey(char c,int i){ this.c=c; this.i=i; }
  char c;
  int i;
}


now i have created some instances and indexed them:
Code:
Holder holder = new Holder();
holder.keys.add(new MyKey('a',1));
holder.keys.add(new MyKey('b',2));
holderService.save(holder);


This works fine and no Problems occurred up to this Point. But if I try to search for an holder which contains a key with c:'a' and i:2 I find the example-holder. Is there a possibility to avoid this? I need to search for only these objects where the two values are in ONE Key.


Top
 Profile  
 
 Post subject: Re: Hibernate Search IndexedEmbedded
PostPosted: Thu Aug 13, 2009 3:36 am 
Newbie

Joined: Wed Aug 12, 2009 11:17 am
Posts: 3
Can anyone help me please?


Top
 Profile  
 
 Post subject: Re: Hibernate Search IndexedEmbedded
PostPosted: Thu Aug 13, 2009 7:36 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
As you are doing you put the 2 parts of the key separated in the index, and mix them with the other fields of other keys: you'll get a bag of chars and ints, without any relation; so the query is going to look for the two values, not necessarily related to the same key.

You want to keep them related in pairs: I'd suggest defining a ClassBridge on "MyKey" to create a single-string encoding of char+int,
or using a FieldBridge on the Set itself returning something like "a1 b5 v7 h7" and have the field tokenized on whitespaces.

With both solutions however you'll need to search for something like "keys:a1" , not separating the two values; this seems more correct IMHO, if the key is defined like that you need one string to identify it.

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


Top
 Profile  
 
 Post subject: Re: Hibernate Search IndexedEmbedded
PostPosted: Thu Aug 13, 2009 8:02 am 
Newbie

Joined: Wed Aug 12, 2009 11:17 am
Posts: 3
Thanks for your Reply.

I did a Workaround like this already. The example was very abstract, in reality there are two texts.

But for now it looks like I have to live with it.


Top
 Profile  
 
 Post subject: Re: Hibernate Search IndexedEmbedded
PostPosted: Sun Aug 16, 2009 10:29 am 
Newbie

Joined: Sun Aug 16, 2009 10:21 am
Posts: 1
Thank you for the discussion, I am suffering this problem too
Jenny craig


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