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 = fullTextSession.createFullTextQuery( query );
    List result = hibQuery.list();
    assertNotNull( result );
    assertEquals( "2 entities should be loaded", 2, stats.getEntityLoadCount() );
    if ( !enabled ) {
      stats.setStatisticsEnabled( false );
    }
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

    tx = s.beginTransaction();
    FullTextSession fts = Search.getFullTextSession( s );
    QueryParser parser = new QueryParser( TestConstants.getTargetLuceneVersion(), "id", TestConstants.stopAnalyzer );

    FullTextQuery fullTextQuery = fts.createFullTextQuery( parser.parse( "body:message" ) );
    List results = fullTextQuery.list();
    assertEquals( "Query with no filter should bring back results from both shards.", 2, results.size() );

    // index is not a field on the entity; the only way to filter on this is by shard
    fullTextQuery.enableFullTextFilter( "shard" ).setParameter( "index", 0 );
    assertEquals( "Query with filter should bring back results from only one shard.", 1, fullTextQuery.list().size() );
View Full Code Here

    List results = fullTextQuery.list();
    assertEquals( "Query with no filter should bring back results from both shards.", 2, results.size() );

    // index is not a field on the entity; the only way to filter on this is by shard
    fullTextQuery.enableFullTextFilter( "shard" ).setParameter( "index", 0 );
    assertEquals( "Query with filter should bring back results from only one shard.", 1, fullTextQuery.list().size() );

    for ( Object o : results ) {
      s.delete( o );
    }
    tx.commit();
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"
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

    MultiFieldQueryParser parser = new MultiFieldQueryParser( TestConstants.getTargetLuceneVersion(), new String[] {"title", "description"},
        TestConstants.standardAnalyzer, boosts );
    Query luceneQuery = parser.parse( "dark" );
    FullTextQuery ftQuery = s.createFullTextQuery( luceneQuery, Dvd.class )
        .setProjection( FullTextQuery.DOCUMENT_ID, FullTextQuery.EXPLANATION, FullTextQuery.THIS );
    @SuppressWarnings("unchecked") List<Object[]> results = ftQuery.list();
    assertEquals( 2, results.size() );
    for ( Object[] result : results ) {
      assertEquals( ftQuery.explain( (Integer) result[0] ).toString(), result[1].toString() );
      s.delete( result[2] );
    }
View Full Code Here

    FullTextQuery allKernelsQuery = fullTextSession.createFullTextQuery( new MatchAllDocsQuery() )
        .initializeObjectsWith( ObjectLookupMethod.SECOND_LEVEL_CACHE, DatabaseRetrievalMethod.QUERY );

    //Identify the mismatch between index/database:
    assertThat( allKernelsQuery.getResultSize() ).isEqualTo( 2 );
    assertThat( allKernelsQuery.list() ).hasSize( 1 );
  }

  private void setData(Session session, Statistics statistics) {
    Transaction transaction = session.beginTransaction();
    StrictKernel k = new StrictKernel();
View Full Code Here

  private void assertEmailsFound(String termMatch, int expectedMatches) {
    FullTextSession fullTextSession = node.openFullTextSession();
    try {
      TermQuery termQuery = new TermQuery( new Term( "message", termMatch ) );
      FullTextQuery fullTextQuery = fullTextSession.createFullTextQuery( termQuery, SimpleEmail.class );
      List<SimpleEmail> list = fullTextQuery.list();
      Assert.assertEquals( expectedMatches, list.size() );
      if ( expectedMatches != 0 ) {
        Assert.assertEquals( "complaints-office@world.com", list.get( 0 ).to );
      }
    }
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.