Package org.hibernate.search

Examples of org.hibernate.search.FullTextQuery.list()


    assertEquals( "Exection of getResultSize without actual results", 2, hibQuery.getResultSize() );
    assertEquals( "No entity should be loaded", 0, stats.getEntityLoadCount() );

    query = parser.parse( "summary:Festina Or brand:Seiko" );
    hibQuery = s.createFullTextQuery( query );
    List result = hibQuery.list();
    assertNotNull( result );
    assertEquals( "2 entities should be loaded", 2, stats.getEntityLoadCount() );
    if ( !enabled ) stats.setStatisticsEnabled( false );
    for (Object element : s.createQuery( "from java.lang.Object" ).list()) s.delete( element );
    tx.commit();
View Full Code Here


    FullTextSession fullTextSession = Search.getFullTextSession( sessions.openSession() );
    Transaction tx = fullTextSession.beginTransaction();
    TermQuery ftQuery = new TermQuery( new Term( "stops.roadName", analyzedRoadname ) );
    FullTextQuery query = fullTextSession.createFullTextQuery( ftQuery, BusLine.class );
    query.setProjection( "busLineName" );
    assertEquals( 1, query.list().size() );
    List results = query.list();
    String resultName = (String) ((Object[])results.get(0))[0];
    assertEquals( "Linea 64", resultName );
    tx.commit();
    fullTextSession.close();
View Full Code Here

    Transaction tx = fullTextSession.beginTransaction();
    TermQuery ftQuery = new TermQuery( new Term( "stops.roadName", analyzedRoadname ) );
    FullTextQuery query = fullTextSession.createFullTextQuery( ftQuery, BusLine.class );
    query.setProjection( "busLineName" );
    assertEquals( 1, query.list().size() );
    List results = query.list();
    String resultName = (String) ((Object[])results.get(0))[0];
    assertEquals( "Linea 64", resultName );
    tx.commit();
    fullTextSession.close();
  }
View Full Code Here

    tx = s.beginTransaction();
    QueryParser parser = new QueryParser( "name", new StandardAnalyzer() );
    Query query = parser.parse( "name:foo" );
    FullTextQuery hibQuery = s.createFullTextQuery( query );
    try {
      hibQuery.list();
      fail();
    }
    catch ( HibernateException e ) {
      assertTrue( "Wrong message", e.getMessage().startsWith( "There are no mapped entities" ) );
    }
View Full Code Here

      // Search
      FullTextSession ftSession = Search.getFullTextSession( sf.openSession(  ) );
      final FullTextQuery textQuery = ftSession.createFullTextQuery( q, Boat.class )
          .setMaxResults( 100 ).setProjection( "name" );
      long start = System.currentTimeMillis();
      List results = textQuery.list();
      int resultSize = textQuery.getResultSize();
      long totalTime = System.currentTimeMillis() - start;
      ftSession.close();
//      log.error( "HSearch [ Thread-id : " + threadId + " ] Total time taken for search is : " + totalTime + "ms with total no. of matching records : " + resultSize );
      setTime( totalTime );
View Full Code Here

      query = getQuery( "green", parser, s );
      random.nextInt( query.getResultSize() - 15 );
      query.setFirstResult( random.nextInt( query.getResultSize() - 15 ) );
      query.setMaxResults( 10 );
      query.list();
      tx.commit();
      s.close();

      s = sf.openSession();
      tx = s.beginTransaction();
View Full Code Here

      query = getQuery( "thief", parser, s );
      int firstResult = random.nextInt( query.getResultSize() - 15 );
      query.setFirstResult( firstResult );
      query.setMaxResults( 10 );
      List result = query.list();
      Object object = result.get( 0 );
      if ( insert && object instanceof Detective ) {
        Detective detective = ( Detective ) object;
        detective.setPhysicalDescription( detective.getPhysicalDescription() + " Eye" + firstResult );
      }
View Full Code Here

    FullTextSession s = Search.getFullTextSession( sess );
    tx = s.beginTransaction();
    QueryParser parser = new QueryParser( "title", new KeywordAnalyzer() );
    Query query = parser.parse( "name:moo" );
    FullTextQuery hibQuery = s.createFullTextQuery( query, Author.class, Music.class );
    List result = hibQuery.list();
    assertEquals( "Should have returned no author", 0, result.size() );

    for (Object o : s.createCriteria( Object.class ).list()) {
      s.delete( o );
    }
View Full Code Here

      query = getQuery( "london", parser, s );
      random.nextInt( query.getResultSize() - 15 );
      query.setFirstResult( random.nextInt( query.getResultSize() - 15 ) );
      query.setMaxResults( 10 );
      query.list();
      tx.commit();
      s.close();

      s = sf.openSession();
      tx = s.beginTransaction();
View Full Code Here

      query = getQuery( "green", parser, s );
      random.nextInt( query.getResultSize() - 15 );
      query.setFirstResult( random.nextInt( query.getResultSize() - 15 ) );
      query.setMaxResults( 10 );
      query.list();
      tx.commit();
      s.close();
    }

    private FullTextQuery getQuery(String queryString, QueryParser parser, Session s) {
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.