Examples of spatial()


Examples of org.hibernate.search.query.dsl.QueryBuilder.spatial()

    Transaction transaction = fullTextSession.beginTransaction();
    final QueryBuilder builder = fullTextSession.getSearchFactory()
        .buildQueryBuilder().forEntity( POI.class ).get();

    Coordinates coordinates = Point.fromDegrees( 24d, 31.5d );
    Query query = builder
        .spatial()
          .onCoordinates( "location" )
          .within( 51, Unit.KM )
            .ofCoordinates( coordinates )
          .createQuery();
View Full Code Here

Examples of org.hibernate.search.query.dsl.QueryBuilder.spatial()

    List<?> results = fullTextSession.createFullTextQuery( query, POI.class ).list();

    assertEquals( "test spatial hash based spatial query", 1, results.size() );
    assertEquals( "test spatial hash based spatial query", "Bozo", ( (POI) results.get( 0 ) ).getName() );

    query = builder
        .spatial()
          .onCoordinates( "location" )
          .within( 500, Unit.KM )
            .ofLatitude( 48.858333d ).andLongitude( 2.294444d )
          .createQuery();
View Full Code Here

Examples of org.hibernate.search.query.dsl.QueryBuilder.spatial()

    double centerLongitude = 32.0d;

    final QueryBuilder builder = fullTextSession.getSearchFactory()
        .buildQueryBuilder().forEntity( POI.class ).get();

    org.apache.lucene.search.Query luceneQuery = builder.spatial().onCoordinates( "location" )
        .within( 100, Unit.KM ).ofLatitude( centerLatitude ).andLongitude( centerLongitude ).createQuery();

    FullTextQuery hibQuery = fullTextSession.createFullTextQuery( luceneQuery, POI.class );
    hibQuery.setProjection( FullTextQuery.THIS, FullTextQuery.SPATIAL_DISTANCE );
    hibQuery.setSpatialParameters( centerLatitude, centerLongitude, "location" );
View Full Code Here

Examples of org.hibernate.search.query.dsl.QueryBuilder.spatial()

    double centerLongitude = 32.0d;

    final QueryBuilder builder = fullTextSession.getSearchFactory()
        .buildQueryBuilder().forEntity( POI.class ).get();

    org.apache.lucene.search.Query luceneQuery = builder.spatial().onCoordinates( "location" )
        .within( 100, Unit.KM ).ofLatitude( centerLatitude ).andLongitude( centerLongitude ).createQuery();

    FullTextQuery hibQuery = fullTextSession.createFullTextQuery( luceneQuery, POI.class );
    Sort distanceSort = new Sort( new DistanceSortField( centerLatitude, centerLongitude, "location" ) );
    hibQuery.setSort( distanceSort );
View Full Code Here

Examples of org.hibernate.search.query.dsl.QueryBuilder.spatial()

  public void testSpatialQueryOnNonSpatialConfiguredEntityThrowsException() throws Exception {
    final QueryBuilder builder = fullTextSession.getSearchFactory()
        .buildQueryBuilder().forEntity( MissingSpatialPOI.class ).get();

    try {
      builder.spatial()
          .onDefaultCoordinates()
          .within( 1, Unit.KM )
          .ofLatitude( 0d )
          .andLongitude( 0d )
          .createQuery();
View Full Code Here

Examples of org.hibernate.search.query.dsl.QueryBuilder.spatial()

  public void testSpatialQueryOnWrongFieldThrowsException() throws Exception {
    final QueryBuilder builder = fullTextSession.getSearchFactory()
        .buildQueryBuilder().forEntity( POI.class ).get();

    try {
      builder.spatial()
          .onCoordinates( "foo" )
          .within( 1, Unit.KM )
          .ofLatitude( 0d )
          .andLongitude( 0d )
          .createQuery();
View Full Code Here

Examples of org.hibernate.search.query.dsl.QueryBuilder.spatial()

    double centerLongitude = 31.5;

    final QueryBuilder builder = fullTextSession.getSearchFactory()
        .buildQueryBuilder().forEntity( Event.class ).get();

    org.apache.lucene.search.Query luceneQuery = builder.spatial().onCoordinates( "location" )
        .within( 50, Unit.KM ).ofLatitude( centerLatitude ).andLongitude( centerLongitude ).createQuery();

    org.hibernate.Query hibQuery = fullTextSession.createFullTextQuery( luceneQuery, Event.class );
    List results = hibQuery.list();
    Assert.assertEquals( 0, results.size() );
View Full Code Here

Examples of org.hibernate.search.query.dsl.QueryBuilder.spatial()

    org.hibernate.Query hibQuery = fullTextSession.createFullTextQuery( luceneQuery, Event.class );
    List results = hibQuery.list();
    Assert.assertEquals( 0, results.size() );

    org.apache.lucene.search.Query luceneQuery2 = builder.spatial().onCoordinates( "location" )
        .within( 51, Unit.KM ).ofLatitude( centerLatitude ).andLongitude( centerLongitude ).createQuery();

    org.hibernate.Query hibQuery2 = fullTextSession.createFullTextQuery( luceneQuery2, Event.class );
    List results2 = hibQuery2.list();
    Assert.assertEquals( 1, results2.size() );
View Full Code Here

Examples of org.hibernate.search.query.dsl.QueryBuilder.spatial()

    double centerLongitude = 31.5;

    final QueryBuilder builder = fullTextSession.getSearchFactory()
        .buildQueryBuilder().forEntity( User.class ).get();

    org.apache.lucene.search.Query luceneQuery = builder.spatial().onCoordinates( "home" )
        .within( 50, Unit.KM ).ofLatitude( centerLatitude ).andLongitude( centerLongitude ).createQuery();

    org.hibernate.Query hibQuery = fullTextSession.createFullTextQuery( luceneQuery, User.class );
    List results = hibQuery.list();
    Assert.assertEquals( 0, results.size() );
View Full Code Here

Examples of org.hibernate.search.query.dsl.QueryBuilder.spatial()

    org.hibernate.Query hibQuery = fullTextSession.createFullTextQuery( luceneQuery, User.class );
    List results = hibQuery.list();
    Assert.assertEquals( 0, results.size() );

    org.apache.lucene.search.Query luceneQuery2 = builder.spatial().onCoordinates( "home" )
        .within( 51, Unit.KM ).ofLatitude( centerLatitude ).andLongitude( centerLongitude ).createQuery();

    org.hibernate.Query hibQuery2 = fullTextSession.createFullTextQuery( luceneQuery2, User.class );
    List results2 = hibQuery2.list();
    Assert.assertEquals( 1, results2.size() );
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.