-->
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.  [ 3 posts ] 
Author Message
 Post subject: Hibernate search 4.2.0.Beta2 - sort-by-distance exception
PostPosted: Sun Nov 11, 2012 5:13 am 
Newbie

Joined: Sun Nov 11, 2012 4:54 am
Posts: 2
I'm trying to use the new functionality: Spatial Queries sorted by distance

This is my query:

Code:
       final QueryBuilder builder = fullTextEntityManager.getSearchFactory().buildQueryBuilder().forEntity( Myclass.class ).get();
   
         double centerLatitude= lat.doubleValue();
         double centerLongitude= lng.doubleValue();
   
         Query luceneQuery = builder.spatial().onCoordinates( "location" ).within( radius, unit ).ofLatitude( centerLatitude ).andLongitude( centerLongitude ).createQuery();
      
         FullTextQuery hibQuery = fullTextEntityManager.createFullTextQuery( luceneQuery,   Myclass.class );
                        //begin - distanceSort block
         Sort distanceSort = new Sort( new DistanceSortField( centerLatitude, centerLongitude, "location" ) );
         hibQuery.setSort( distanceSort );
         hibQuery.setProjection( FullTextQuery.THIS, FullTextQuery.SPATIAL_DISTANCE );
         hibQuery.setSpatialParameters( centerLatitude, centerLongitude, "location" );
                        //end - distanceSort block
         hibQuery.setFirstResult(5*index);
         hibQuery.setMaxResults(5);      
              hibQuery.getResultList();


The code gives me this java exception On "hibQuery.getResultList()"

java.lang.ArrayIndexOutOfBoundsException: 10
at org.hibernate.search.spatial.impl.DistanceComparator.setNextReader(DistanceComparator.java:77)
at org.apache.lucene.search.TopFieldCollector$OneComparatorNonScoringCollector.setNextReader(TopFieldCollector.java:95)
at org.hibernate.search.spatial.impl.DistanceCollector.setNextReader(DistanceCollector.java:69)
at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:576)
at org.hibernate.search.query.engine.impl.QueryHits.updateTopDocs(QueryHits.java:243)
at org.hibernate.search.query.engine.impl.QueryHits.<init>(QueryHits.java:144)
at org.hibernate.search.query.engine.impl.HSQueryImpl.getQueryHits(HSQueryImpl.java:457)
at org.hibernate.search.query.engine.impl.HSQueryImpl.queryEntityInfos(HSQueryImpl.java:254)
at org.hibernate.search.query.hibernate.impl.FullTextQueryImpl.list(FullTextQueryImpl.java:209)
at org.hibernate.search.jpa.impl.FullTextQueryImpl.getResultList(FullTextQueryImpl.java:160)

My query without "distanceSort block code" works very well, and gives me 2 result records.
It is my code problem or it is a hibernate search bug?


Top
 Profile  
 
 Post subject: Re: Hibernate search 4.2.0.Beta2 - sort-by-distance exception
PostPosted: Tue Nov 13, 2012 7:01 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hi,
I think you've hit one of:
https://hibernate.onjira.com/browse/HSEARCH-1219 (a patch was proposed on github - not merged yet but you're welcome to try it out: links on JIRA)
https://hibernate.onjira.com/browse/HSEARCH-1220 (resolved - welcome to try master)

Would you be able to verify them or create a unit test? Otherwise you could wait for the next tag which will include both, that will happen in two weeks.

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


Top
 Profile  
 
 Post subject: Re: Hibernate search 4.2.0.Beta2 - sort-by-distance exception
PostPosted: Tue Nov 13, 2012 7:54 am 
Newbie

Joined: Sun Nov 11, 2012 4:54 am
Posts: 2
Many thanks for your answer, I'm sure that my problem is due to what is reported in the bug
https://hibernate.onjira.com/browse/HSEARCH-1219 I will wait for the next release and I will do more tests.


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