-->
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 seach + Hibernate spatial integration ?
PostPosted: Wed Jan 07, 2009 9:39 am 
Newbie

Joined: Tue Dec 23, 2008 10:42 am
Posts: 7
Hi guys,

I'm integrating hibernate search in a local search project. Is there a way to index and query spatial objects.

We have a database of geo-located places and it would be really great to perform hibernate search + spatial queries.

We need to migrate (from standard EJB/QL to using hibernate search queries) this query for exemple :

Code:
String qBuf = "select poi " +
"from POI as poi " +
"where LOWER(poi.nameBase) LIKE :poiName " +
" AND poi.revisionState = :revState " +
" AND spatial.X(poi.location) < :xMax " +
" AND spatial.X(poi.location) > :xMin " +
" AND spatial.Y(poi.location) < :yMax " +
" AND spatial.Y(poi.location) > :yMin " +
"order by poi.nbBookmark DESC " +
" , poi.nbReview DESC " +
" , poi.nameBase ASC";
Query q = em.createQuery(qBuf);
q.setParameter("poiName", "%" + poiName.toLowerCase() + "%");
q.setParameter("revState", RevisionState.ACT);
q.setParameter("xMax", northEastLng);
q.setParameter("xMin", southWestLng);
q.setParameter("yMax", northEastLat);
q.setParameter("yMin", southWestLat);
q.setFirstResult(offset);
q.setMaxResults(maxResult);

return (List<POI>) q.getResultList();


Data are stored in a postgresql database + postgis. We use the original library from Norman Barker to map and query the spatial columns with JPA and EJB3 (it has been taken over by http://www.hibernatespatial.org now I guess).

I asked the same question to Norman Barker. Here is his answer :


Quote:
-----------------------------------------------------
Romain,

your site looks very good. The EJB3 code in PostGIS has been used by
several companies, and it works, however I think it has been taken
over by http://www.hibernatespatial.org now, but the code is still in
SVN for reference and I prefer it since it is very simple.

I have not seriously looked into hooking up hibernate search and
postgis, though I think it would be possible. A good first start
would be hook to up the OpenSearch interface with perhaps the
geographic extensions? Hibernate search just returns the primary keys
of the entity matching the input search terms so I think hooking the
two together would be very simple.

Good luck with your site!

Norman
------------------------------------------------


Did someone already investigate this ?

Thanks for your help.

_________________
Romain


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 08, 2009 7:02 am 
Hibernate Team
Hibernate Team

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

I've haven't heard of hibernatespatial until now, but after a short glance it seems to extend Hibernate by adding a custom user type and some extensions for HQL - the aim being to abstract from database specific differences in handling geospatial data.

Even though you should be able to index your spatial data with Hibernate Search, the question is whether there could be a true synergy effect between hibernatespatial and Hibernate Search. I am not so sure about that. It seems that once you use Lucene for doing your spatial searches there is no need anymore for the custom HQL part or for hibernatespatial as a matter of fact.

You also have to remember that Lucene is really a fulltext search engine. For efficient geospatial searches a different type of index (spatial index) is needed. There are, however, ways to do this in Lucene. Have for example a look at this blog. Or search for Local Lucene.

I think your usecase can be solved with Hibernate Search, but with or without hibernatespatial I am not sure. My gut feeling is that it would not be needed.

It is an interesting question though. Feel free to keep us updated about your investigations. Maybe we can help with some other questions.

--Hardy


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 08, 2009 7:02 am 
Hibernate Team
Hibernate Team

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

I've haven't heard of hibernatespatial until now, but after a short glance it seems to extend Hibernate by adding a custom user type and some extensions for HQL - the aim being to abstract from database specific differences in handling geospatial data.

Even though you should be able to index your spatial data with Hibernate Search, the question is whether there could be a true synergy effect between hibernatespatial and Hibernate Search. I am not so sure about that. It seems that once you use Lucene for doing your spatial searches there is no need anymore for the custom HQL part or for hibernatespatial as a matter of fact.

You also have to remember that Lucene is really a fulltext search engine. For efficient geospatial searches a different type of index (spatial index) is needed. There are, however, ways to do this in Lucene. Have for example a look at this blog. Or search for Local Lucene.

I think your usecase can be solved with Hibernate Search, but with or without hibernatespatial I am not sure. My gut feeling is that it would not be needed.

It is an interesting question though. Feel free to keep us updated about your investigations. Maybe we can help with some other questions.

--Hardy


Top
 Profile  
 
 Post subject: Re: Hibernate seach + Hibernate spatial integration ?
PostPosted: Thu Jul 01, 2010 3:20 am 
Newbie

Joined: Wed Jan 09, 2008 6:36 pm
Posts: 1
wouldnt it make sense to now better integrate hibernate-search with lucene spatial contrib?
ref: http://wiki.apache.org/lucene-java/SpatialSearch


Top
 Profile  
 
 Post subject: Re: Hibernate seach + Hibernate spatial integration ?
PostPosted: Fri Jul 02, 2010 2:16 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Yes I assume the lucene spatial is interesting; Lucene developers are working hard the latest months on efficient location/spatial queries; AFAIK it's not totally finished but ready to be tested out.
It looks like this is only a matter of defining some custom types and String-bridges? you're welcome to try it out and share your findings.
Hibernate Search doesn't interfere with the way you create your queries, so as long as you manage to map your coordinates to the index it should be straight forward.

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


Top
 Profile  
 
 Post subject: Re: Hibernate seach + Hibernate spatial integration ?
PostPosted: Mon Jul 05, 2010 4:28 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
FYI, since the post of the first message on this thread the Hibernate Team has contacted Karel Maesen who is the lead developer of Hibernate Spatial. The idea is make Hibernate Spatial a module/sub-project of Hibernate. You can find more about this effort by searching the hibernate-dev mailing list.
I am not sure yet how Search will be able to benefit from Hibernate Spatial and where and how the Lucene efforts fit in. We need to evaluate where we are going with this.

--Hardy


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.