Package org.hibernate.search

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


  public void testBoostedFieldDesc() throws Exception {
    FullTextSession fullTextSession = Search.getFullTextSession( openSession() );
    buildBoostedFieldIndex( fullTextSession );

    fullTextSession.clear();
    Transaction tx = fullTextSession.beginTransaction();

    QueryParser authorParser = new QueryParser( "author", new StandardAnalyzer() );
    QueryParser descParser = new QueryParser( "description", new StandardAnalyzer() );
    Query author = authorParser.parse( "Wells" );
    Query desc = descParser.parse( "martians" );
View Full Code Here


  public void testBoostedDesc() throws Exception {
    FullTextSession fullTextSession = Search.getFullTextSession( openSession() );
    buildBoostedDescIndex( fullTextSession );

    fullTextSession.clear();
    Transaction tx = fullTextSession.beginTransaction();

    QueryParser authorParser = new QueryParser( "author", new StandardAnalyzer() );
    QueryParser descParser = new QueryParser( "description", new StandardAnalyzer() );
    Query author = authorParser.parse( "Wells" );
    Query desc = descParser.parse( "martians" );
View Full Code Here

   * @throws Exception in case the test fails.
   */
  public void testNoWorkDuplication() throws Exception {

    FullTextSession s = org.hibernate.search.Search.getFullTextSession( openSession() );
    Transaction tx = s.beginTransaction();

    // create new customer
    SpecialPerson person = new SpecialPerson();
    person.setName( "Joe Smith" );

View Full Code Here

    // persist the customer
    s.persist( person );
    tx.commit();

    // search if the record made it into the index
    tx = s.beginTransaction();
    String searchQuery = "Joe";
    QueryParser parser = new QueryParser( "Content", new StandardAnalyzer() );
    Query luceneQuery = parser.parse( searchQuery );
    FullTextQuery query = s.createFullTextQuery( luceneQuery );
    List results = query.list();
View Full Code Here

    List results = query.list();
    assertTrue( "We should have a hit", results.size() == 1 );
    tx.commit();

    // Now try to delete
    tx = s.beginTransaction();
    int id = person.getId();
    person = ( SpecialPerson ) s.get( SpecialPerson.class, id );
    s.delete( person );
    tx.commit();
View Full Code Here

    person = ( SpecialPerson ) s.get( SpecialPerson.class, id );
    s.delete( person );
    tx.commit();

    // Search and the record via Lucene directly
    tx = s.beginTransaction();

    DirectoryProvider directoryProvider = s.getSearchFactory().getDirectoryProviders( SpecialPerson.class )[0];
    ReaderProvider readerProvider = s.getSearchFactory().getReaderProvider();
    IndexReader reader = readerProvider.openReader( directoryProvider );
    IndexSearcher searcher = new IndexSearcher( reader );
View Full Code Here

*/
public class LuceneQueryTest extends SearchTestCase {

  public void testList() throws Exception {
    FullTextSession s = Search.getFullTextSession( openSession() );
    Transaction tx = s.beginTransaction();
    Clock clock = new Clock( 1, "Seiko" );
    s.save( clock );
    clock = new Clock( 2, "Festina" );
    s.save( clock );
    Book book = new Book( 1, "La chute de la petite reine a travers les yeux de Festina", "La chute de la petite reine a travers les yeux de Festina, blahblah" );
View Full Code Here

    s.save( book );
    book = new Book( 2, "La gloire de mon p�re", "Les deboires de mon p�re en v�lo" );
    s.save( book );
    tx.commit();
    s.clear();
    tx = s.beginTransaction();
    QueryParser parser = new QueryParser( "title", new StopAnalyzer() );

    Query query = parser.parse( "summary:noword" );
    org.hibernate.Query hibQuery = s.createFullTextQuery( query, Clock.class, Book.class );
    List result = hibQuery.list();
View Full Code Here

    s.close();
  }

  public void testResultSize() throws Exception {
    FullTextSession s = Search.getFullTextSession( openSession() );
    Transaction tx = s.beginTransaction();
    Clock clock = new Clock( 1, "Seiko" );
    s.save( clock );
    clock = new Clock( 2, "Festina" );
    s.save( clock );
    Book book = new Book( 1, "La chute de la petite reine a travers les yeux de Festina", "La chute de la petite reine a travers les yeux de Festina, blahblah" );
View Full Code Here

    s.save( book );
    book = new Book( 2, "La gloire de mon p�re", "Les deboires de mon p�re en v�lo" );
    s.save( book );
    tx.commit();
    s.clear();
    tx = s.beginTransaction();
    QueryParser parser = new QueryParser( "title", new StopAnalyzer() );

    Query query = parser.parse( "summary:Festina Or brand:Seiko" );
    Statistics stats = s.getSessionFactory().getStatistics();
    stats.clear();
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.