Package org.apache.lucene.analysis

Examples of org.apache.lucene.analysis.StopAnalyzer


  }

  public void testSearchUnindexClass() throws Exception {
    createTestData();

    QueryParser parser = new QueryParser( "name", new StopAnalyzer() );
    Query query = parser.parse( "Elephant" );

    FullTextSession s = Search.getFullTextSession( openSession() );
    Transaction tx = s.beginTransaction();
    try {
View Full Code Here


    createTestData();

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

    QueryParser parser = new QueryParser( "name", new StopAnalyzer() );
    Query query = parser.parse( "Elephant" );
    org.hibernate.Query hibQuery = s.createFullTextQuery( query, Mammal.class );
    assertItsTheElephant( hibQuery.list() );

    query = parser.parse( "Elephant" );
View Full Code Here

  public void testPolymorphicQueries() throws Exception {
    createTestData();

    FullTextSession s = Search.getFullTextSession( openSession() );
    Transaction tx = s.beginTransaction();
    QueryParser parser = new QueryParser( "name", new StopAnalyzer() );
    Query query = parser.parse( "Elephant" );

    org.hibernate.Query hibQuery = s.createFullTextQuery( query, Mammal.class );
    assertItsTheElephant( hibQuery.list() );
View Full Code Here

    }
    s.close();
  }

  private void assertNumberOfAnimals(FullTextSession s, int count) throws Exception {
    QueryParser parser = new QueryParser( "name", new StopAnalyzer() );
    Query query = parser.parse( "Elephant OR White Pointer OR Chimpanzee OR Dove or Eagle" );
    List result = s.createFullTextQuery( query, Animal.class ).list();
    assertNotNull( result );
    assertEquals( "Wrong number of hits. There should be one elephant and one shark.", count, result.size() );
  }
View Full Code Here

      if ( index % 5 == 0 ) s.clear();
    }
    tx.commit();
    s.clear();
    tx = s.beginTransaction();
    QueryParser parser = new QueryParser( "id", new StopAnalyzer() );
    List result = s.createFullTextQuery( parser.parse( "body:create" ) ).list();
    assertEquals( 14, result.size() );
    for (Object object : result) {
      s.delete( object );
    }
View Full Code Here

    s.close();

    //check non created object does get found!!1
    s = new FullTextSessionImpl( openSession() );
    tx = s.beginTransaction();
    QueryParser parser = new QueryParser( "id", new StopAnalyzer() );
    List result = s.createFullTextQuery( parser.parse( "body:create" ) ).list();
    assertEquals( 0, result.size() );
    tx.commit();
    s.close();

    s = new FullTextSessionImpl( openSession() );
    s.getTransaction().begin();
    Statement stmt = s.connection().createStatement();
    stmt.executeUpdate( "update Email set body='Meet the guys who write the software'" );
    stmt.close();
    //insert an object never indexed
    stmt = s.connection().createStatement();
    stmt.executeUpdate( "insert into Email(id, title, body, header) values( + "
        + ( loop + 1 ) + ", 'Bob Sponge', 'Meet the guys who create the software', 'nope')" );
    stmt.close();
    s.getTransaction().commit();
    s.close();

    s = new FullTextSessionImpl( openSession() );
    tx = s.beginTransaction();
    parser = new QueryParser( "id", new StopAnalyzer() );
    result = s.createFullTextQuery( parser.parse( "body:write" ) ).list();
    assertEquals( 0, result.size() );
    result = s.createCriteria( Email.class ).list();
    for (int i = 0; i < loop / 2; i++)
      s.index( result.get( i ) );
View Full Code Here

    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();
    assertNotNull( result );
View Full Code Here

    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();
    boolean enabled = stats.isStatisticsEnabled();
View Full Code Here

    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" );
    org.hibernate.Query hibQuery = s.createFullTextQuery( query, Clock.class, Book.class );
    hibQuery.setFirstResult( 1 );
    List result = hibQuery.list();
View Full Code Here

    book = new Book( 2, "La gloire de mon p�re", "Les deboires de mon p�re en v�lo" );
    s.save( book );
    tx.commit();//post commit events for lucene
    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 );
    Iterator result = hibQuery.iterate();
    assertNotNull( result );
View Full Code Here

TOP

Related Classes of org.apache.lucene.analysis.StopAnalyzer

Copyright © 2018 www.massapicom. 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.