-->
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.  [ 1 post ] 
Author Message
 Post subject: How to set projection on distance search with search 4.2.0
PostPosted: Tue Jan 29, 2013 12:22 am 
Regular
Regular

Joined: Fri Feb 04, 2011 8:34 pm
Posts: 66
Hi,

With Hibernate-search 4.2.0, I don't know how apply project on distance search.

Here is my code:

Code:
EntityManager em = emf.createEntityManager();
        FullTextEntityManager fullTextEntityManager = org.hibernate.search.jpa.Search.getFullTextEntityManager(em);
        try {
            fullTextEntityManager.createIndexer().startAndWait();
        } catch (InterruptedException ex) {
            java.util.logging.Logger.getLogger(MyisamProductArticleFacade.class.getName()).log(Level.SEVERE, null, ex);
        }
        String termsStr = terms.toLowerCase();
        QueryBuilder qb = fullTextEntityManager.getSearchFactory().buildQueryBuilder().forEntity( MyisamProductArticle.class ).get();
        org.apache.lucene.search.Query query = null;
query = qb
                        .bool()
                            .must(qb.keyword().onField("state").matching(state).createQuery())
                            .must(qb.keyword().onField("postcode").matching(postcode).createQuery())
                            .must(qb.spatial()
                                .onDefaultCoordinates()
                                .within( radius, Unit.KM )
                                .ofLatitude( lat )
                                .andLongitude( lon ).createQuery())
                        .createQuery();


Compared to the example given by http://docs.jboss.org/hibernate/search/4.2/reference/en-US/html/spatial.html :

Code:
FullTextQuery hibQuery = fullTextSession.createFullTextQuery(luceneQuery, POI.class);
query.setProjection(FullTextQuery.SPATIAL_DISTANCE, FullTextQuery.THIS);
query.setSpatialParameters(centerLatitude, centerLongitude, "location");
List results = hibQuery.list();


I don't know how to mix them together.

Any suggestion is very appreciated.
Thank you for the good work.
Samuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.