-->
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: Spatial search in lists
PostPosted: Fri May 30, 2014 9:51 am 
Beginner
Beginner

Joined: Mon Nov 26, 2012 4:08 am
Posts: 24
Hello!
I have a problem with spatial search.
It seems that if you use onCoordinates on a list of objects, Hibernate Search only returns true if the first object in the list has locations that falls within the range desired.
We are using Hibernate Core 4.3.5.Final, Hibernate Commons Annotations 4.0.4.Final, Hibernate Validator 5.1.0.Final, Hibernate Search 4.5.0.Final, Lucene 3.6.2

Code Example:

Classes:

Code:
@Entity
@Indexed
public Class A {

    @IndexedEmbedded
    @OneToMany(mappedBy = "a", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
    private Set<B> listOfB = new HashSet<B>();
   
    <snip>
   
}

@Entity
@Indexed
public Class B {

    @ContainedIn
    @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE, optional = false)
    @JoinColumn(name = "A_ID", referencedColumnName = "A_ID", nullable = false)
    private A a;
   
    @IndexedEmbedded
    @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE, optional = false)
    @JoinColumn(name = "ADDRESS_ID", referencedColumnName = "ADDRESS_ID", nullable = false)
    private DAddress address;

    <snip>
   
}


@Spatial(name = "location", spatialMode = SpatialMode.RANGE)
@Entity
@Indexed
public Class DAddress {

    @Latitude(of = "location")
    @Column(name = "LATITUDE")
    private Double latitude;

    @Longitude(of = "location")
    @Column(name = "LONGITUDE")
    private Double longitude;   
   
    <snip>
}



Hibernate Search query:

Code:
        FullTextEntityManager fullTextEntityManager = Search.getFullTextEntityManager(this.getEntityManager());
        QueryBuilder queryBuilder = fullTextEntityManager.getSearchFactory().buildQueryBuilder().forEntity(A.class).get();


        BooleanJunction<BooleanJunction> bool = queryBuilder.bool();
        <snip some checks on other fields>
       
        if (referencepoint != null) {
            double maxDistanceInKm = (double) maxDistance / KM;
            bool.must(queryBuilder
                    .spatial()
                    .onCoordinates("listOfB.address.location")
                    .within(maxDistanceInKm, Unit.KM)
                    .ofLatitude(referencepoint.getLatitude())
                    .andLongitude(referencepoint.getLongitude())
                    .createQuery());
        }


Here it seems that I only get a result if the first object in listOfB.address.location matches the latitude/longitude criteria.

If one of the following objects in the list matches, I still won't get a resutlt.

Have I missed something?
Isn't is possible to do spatial search in lists?

Regards
Andreas


Top
 Profile  
 
 Post subject: Re: Spatial search in lists
PostPosted: Thu Jun 05, 2014 6:17 am 
Beginner
Beginner

Joined: Mon Nov 26, 2012 4:08 am
Posts: 24
Bump
Hasn't anyone had this problem? Workaround?
Regards
Andreas


Top
 Profile  
 
 Post subject: Re: Spatial search in lists
PostPosted: Mon Jun 16, 2014 3:10 pm 
Beginner
Beginner

Joined: Mon Nov 26, 2012 4:08 am
Posts: 24
Hasn't anyone had this problem before?
It is still a big problem for us, we can't use spatial search.


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.