Package org.apache.lucene.analysis

Examples of org.apache.lucene.analysis.KeywordAnalyzer


   
    private static void initIndex(Directory directory, int nDocs, boolean create, String contents2) throws IOException {
        IndexWriter indexWriter=null;
       
        try {
            indexWriter=new IndexWriter(directory, new KeywordAnalyzer(), create);
           
            for (int i=0; i<nDocs; i++) {
                indexWriter.addDocument(createDocument("doc" + i, contents2));
            }
        } finally {
View Full Code Here


    Statement statement = sess.connection().createStatement();
    statement.executeUpdate( "DELETE FROM Author" );
    statement.close();
    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() );
View Full Code Here

   
    private static void initIndex(Directory directory, int nDocs, boolean create, String contents2) throws IOException {
        IndexWriter indexWriter=null;
       
        try {
            indexWriter=new IndexWriter(directory, new KeywordAnalyzer(), create);
           
            for (int i=0; i<nDocs; i++) {
                indexWriter.addDocument(createDocument("doc" + i, contents2));
            }
        } finally {
View Full Code Here

   
    private static void initIndex(Directory directory, int nDocs, boolean create, String contents2) throws IOException {
        IndexWriter indexWriter=null;
       
        try {
            indexWriter=new IndexWriter(directory, new KeywordAnalyzer(), create);
           
            for (int i=0; i<nDocs; i++) {
                indexWriter.addDocument(createDocument("doc" + i, contents2));
            }
        } finally {
View Full Code Here

    Statement statement = sess.connection().createStatement();
    statement.executeUpdate( "DELETE FROM Author" );
    statement.close();
    FullTextSession s = Search.createFullTextSession( 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() );
View Full Code Here

    tx.commit();
    sess.clear();

    FullTextSession s = Search.createFullTextSession( sess );
    tx = s.beginTransaction();
    QueryParser parser = new QueryParser( "title", new KeywordAnalyzer() );
    Query query = parser.parse( "title:moo" );
    FullTextQuery hibQuery = s.createFullTextQuery( query, Music.class );
    List result = hibQuery.list();
    assertEquals( "Should have returned 2 Books", 2, result.size() );
    music = (Music) result.get( 0 );
View Full Code Here

  public void testSimple() throws Exception {
    assertQueryEquals("term term term", null, "term term term");
    assertQueryEquals("türm term term", new WhitespaceAnalyzer(), "türm term term");
    assertQueryEquals("ümlaut", new WhitespaceAnalyzer(), "ümlaut");

    assertQueryEquals("\"\"", new KeywordAnalyzer(), "");
    assertQueryEquals("foo:\"\"", new KeywordAnalyzer(), "foo:");

    assertQueryEquals("a AND b", null, "+a +b");
    assertQueryEquals("(a AND b)", null, "+a +b");
    assertQueryEquals("c OR (a AND b)", null, "c (+a +b)");
    assertQueryEquals("a AND NOT b", null, "+a -b");
View Full Code Here

    Statement statement = sess.connection().createStatement();
    statement.executeUpdate( "DELETE FROM Author" );
    statement.close();
    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() );
View Full Code Here

    tx.commit();
    sess.clear();

    FullTextSession s = Search.getFullTextSession( sess );
    tx = s.beginTransaction();
    QueryParser parser = new QueryParser( "title", new KeywordAnalyzer() );
    Query query = parser.parse( "title:moo" );
    FullTextQuery hibQuery = s.createFullTextQuery( query, Music.class );
    List result = hibQuery.list();
    assertEquals( "Should have returned 2 Books", 2, result.size() );
    music = (Music) result.get( 0 );
View Full Code Here

    Directory dir = new RAMDirectory();
    doTestReopenWithCommit(dir, false);
  }

  private void doTestReopenWithCommit (Directory dir, boolean withReopen) throws IOException {
    IndexWriter iwriter = new IndexWriter(dir, new KeywordAnalyzer(), true, MaxFieldLength.LIMITED);
    iwriter.setMergeScheduler(new SerialMergeScheduler());
    IndexReader reader = IndexReader.open(dir);
    try {
      int M = 3;
      for (int i=0; i<4; i++) {
View Full Code Here

TOP

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

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.