-->
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.  [ 4 posts ] 
Author Message
 Post subject: Problem with Street name and Alternative Name
PostPosted: Tue Oct 06, 2009 1:00 pm 
Newbie

Joined: Tue Oct 06, 2009 11:28 am
Posts: 2
Hi,

I have some entity called Street which have one Column named StreetName, this entity have a One-to-many with AlternativeName table which have the same column called StreetAlternativeName, is possible to define some way to perform a query inside this two tables? I mean, I want to search for some String "street" and the query will perform the search inside of both Street and AlternativeName tables and returning the reference to the Street.

I don't know if I'm clear enough to define the problem.

Well, if someone had this same kind of problem, please tell me.
Thank you in advance.


Top
 Profile  
 
 Post subject: Re: Problem with Street name and Alternative Name
PostPosted: Tue Oct 06, 2009 2:56 pm 
Pro
Pro

Joined: Wed Oct 03, 2007 2:31 pm
Posts: 205
Hi

Basically what you want to do is something like this:
Code:
@Indexed
public class Street {
   @Field(<define field values>)
   private String streetName;
 
   @IndexEmbedded
   Set<AlternativeStreetName> streetNames;
   ...
}

public class AlternativeStreetName {
  @Field(<define field>)
  private String alternativeStreetName;
  @ContainedIn
  private Street street;
  ...
}


This should basically allow you to do queries like
streetName
streetNames.alternativeStreetName

You will need to configure the query to return the Street object. You can look at the Hibernate Search documentation for more info.

Hope that helps.

P.S. My mappings may be incorrect but the above gives you a rough idea. Also I would recommend getting Hibernate Search Action which is an invaluable resource if you're building Hibernate Search into your domain model.


Top
 Profile  
 
 Post subject: Re: Problem with Street name and Alternative Name
PostPosted: Tue Oct 06, 2009 4:39 pm 
Newbie

Joined: Tue Oct 06, 2009 11:28 am
Posts: 2
First of all, thank you. That is almost what I want, your solution may help but I want to know if something else work too.

What I want to know is if is possible for a single search in streetName lucene internally try to find in both streetName itself and in streetName.alternativeName too, I mean, streetName.alternativeName should be represented by streetName, understand?

The reason why I want to do this is 'cause Street will rarelly have a StreetAlternativeName but we need to have this mapped and I don't want to perform a search with AND operator 'cause this may interfer in the performance for all the Street which doesn't have a AlternativeName, we have over 1 billion of Streets but only 5k with alternativeName.


Top
 Profile  
 
 Post subject: Re: Problem with Street name and Alternative Name
PostPosted: Wed Oct 07, 2009 7:12 am 
Pro
Pro

Joined: Wed Oct 03, 2007 2:31 pm
Posts: 205
I'm not sure if I follow. Basically is what you're saying is that street may or maynot have alternativeStreetName? The lucene document of Street will look something like this:

streetName
streetNames.alternativeStreetName
streetNames.alternativeStreetName
streetNames.alternativeStreetName
streetNames.alternativeStreetName

or
streetName
//no fields for streetNames.alternativeStreetName

So when you do a search for xyz and if you specifiy fields to search as streetName and streetNames.alternativeStreetName then lucene will search in the street index and search the fields streetName and streetNames.alternativeStreetName and will return a reference to that Street object which Hibernate will retrieve. I would recommend trying the above first and see what the performance implication is. I mean Lucene is very fast so it may be that there is no perfomance impact.

Not sure if that helped.


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