Package org.hibernate.search

Examples of org.hibernate.search.FullTextSession.createFullTextQuery()


    // the Lucene document but not in the Department entity itself.
    QueryParser parser = new QueryParser( "equipment", new SimpleAnalyzer() );

    // Check the second ClassBridge annotation
    Query query = parser.parse( "equiptype:Cisco" );
    org.hibernate.search.FullTextQuery hibQuery = session.createFullTextQuery( query, Departments.class );
    List<Departments> result = hibQuery.list();
    assertNotNull( result );
    assertEquals( "incorrect number of results returned", 2, result.size() );
    for (Departments d : result) {
      assertEquals("incorrect manufacturer", "C", d.getManufacturer());
View Full Code Here


      assertEquals("incorrect manufacturer", "C", d.getManufacturer());
    }

    // No data cross-ups.
    query = parser.parse( "branchnetwork:Kent Lewin" );
    hibQuery = session.createFullTextQuery( query, Departments.class );
    result = hibQuery.list();
    assertNotNull( result );
    assertTrue( "problem with field cross-ups", result.size() == 0 );

    // Non-ClassBridge field.
View Full Code Here

    assertTrue( "problem with field cross-ups", result.size() == 0 );

    // Non-ClassBridge field.
    parser = new QueryParser( "branchHead", new SimpleAnalyzer() );
    query = parser.parse( "branchHead:Kent Lewin" );
    hibQuery = session.createFullTextQuery( query, Departments.class );
    result = hibQuery.list();
    assertNotNull( result );
    assertTrue( "incorrect entity returned, wrong branch head", result.size() == 1 );
    assertEquals("incorrect entity returned", "Kent Lewin", ( result.get( 0 ) ).getBranchHead());
View Full Code Here

    assertEquals("incorrect entity returned", "Kent Lewin", ( result.get( 0 ) ).getBranchHead());

    // Check other ClassBridge annotation.
    parser = new QueryParser( "branchnetwork", new SimpleAnalyzer() );
    query = parser.parse( "branchnetwork:st. george 1D" );
    hibQuery = session.createFullTextQuery( query, Departments.class );
    result = hibQuery.list();
    assertNotNull( result );
    assertEquals( "incorrect entity returned, wrong network", "1D", ( result.get( 0 ) ).getNetwork() );
    assertEquals( "incorrect entity returned, wrong branch", "St. George", ( result.get( 0 ) ).getBranch() );
    assertEquals( "incorrect number of results returned", 1, result.size() );
View Full Code Here

    // the Lucene document but not in the Department entity itself.
    QueryParser parser = new QueryParser( "equipment", new SimpleAnalyzer() );

    // Check the second ClassBridge annotation
    Query query = parser.parse( "equiptype:Cisco" );
    org.hibernate.search.FullTextQuery hibQuery = session.createFullTextQuery( query, Departments.class );

    hibQuery.setProjection( FullTextQuery.THIS, FullTextQuery.DOCUMENT );

    ScrollableResults projections = hibQuery.scroll();
    assertNotNull( projections );
View Full Code Here

    // class. This is in the Lucene document but not in the
    // Department entity itself.
    QueryParser parser = new QueryParser( "branchnetwork", new SimpleAnalyzer() );

    Query query = parser.parse( "branchnetwork:layton 2B" );
    org.hibernate.search.FullTextQuery hibQuery = session.createFullTextQuery( query, Department.class );
    List result = hibQuery.list();
    assertNotNull( result );
    assertEquals( "incorrect entity returned, wrong network", "2B", ( (Department) result.get( 0 ) ).getNetwork() );
    assertEquals( "incorrect entity returned, wrong branch", "Layton", ( (Department) result.get( 0 ) ).getBranch() );
    assertEquals( "incorrect number of results returned", 1, result.size() );
View Full Code Here

    assertEquals( "incorrect entity returned, wrong branch", "Layton", ( (Department) result.get( 0 ) ).getBranch() );
    assertEquals( "incorrect number of results returned", 1, result.size() );

    // Partial match.
    query = parser.parse( "branchnetwork:3c" );
    hibQuery = session.createFullTextQuery( query, Department.class );
    result = hibQuery.list();
    assertNotNull( result );
    assertEquals( "incorrect entity returned, wrong network", "3C", ( (Department) result.get( 0 ) ).getNetwork() );
    assertEquals( "incorrect entity returned, wrong branch", "West Valley", ( (Department) result.get( 0 ) ).getBranch() );
    assertEquals( "incorrect number of results returned", 1, result.size() );
View Full Code Here

    assertEquals( "incorrect entity returned, wrong branch", "West Valley", ( (Department) result.get( 0 ) ).getBranch() );
    assertEquals( "incorrect number of results returned", 1, result.size() );

    // No data cross-ups .
    query = parser.parse( "branchnetwork:Kent Lewin" );
    hibQuery = session.createFullTextQuery( query, Department.class );
    result = hibQuery.list();
    assertNotNull( result );
    assertTrue( "problem with field cross-ups", result.size() == 0 );

    // Non-ClassBridge field.
View Full Code Here

    assertTrue( "problem with field cross-ups", result.size() == 0 );

    // Non-ClassBridge field.
    parser = new QueryParser( "branchHead", new SimpleAnalyzer() );
    query = parser.parse( "branchHead:Kent Lewin" );
    hibQuery = session.createFullTextQuery( query, Department.class );
    result = hibQuery.list();
    assertNotNull( result );
    assertTrue( "incorrect entity returned, wrong branch head", result.size() == 1 );
    assertEquals("incorrect entity returned", "Kent Lewin", ( (Department) result.get( 0 ) ).getBranchHead());
View Full Code Here

    s.clear();
    Transaction tx = s.beginTransaction();
    QueryParser parser = new QueryParser( "dept", new StandardAnalyzer() );

    Query query = parser.parse( "dept:ITech" );
    org.hibernate.search.FullTextQuery hibQuery = s.createFullTextQuery( query, Employee.class );
    hibQuery.setProjection( "id", "lastname", "dept" );
    hibQuery.setFetchSize( 3 );
    hibQuery.setFirstResult( 1 );
    hibQuery.setMaxResults( 3 );
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.