Package org.apache.lucene.analysis

Examples of org.apache.lucene.analysis.StopAnalyzer


  }

  public void testPositionIncrement() throws Exception {
    StandardQueryParser qp = new StandardQueryParser();
    qp.setAnalyzer(
        new StopAnalyzer(TEST_VERSION_CURRENT, StopFilter.makeStopSet(TEST_VERSION_CURRENT, "the", "in", "are", "this" )));

    qp.setEnablePositionIncrements(true);

    String qtxt = "\"the words in poisitions pos02578 are stopped in this phrasequery\"";
    // 0 2 5 7 8
View Full Code Here


    assertEquals(1,type[0]);

  }

  public void testStopwords() throws Exception {
    QueryParser qp = new QueryParser(TEST_VERSION_CURRENT, "a", new StopAnalyzer(TEST_VERSION_CURRENT, StopFilter.makeStopSet(TEST_VERSION_CURRENT, "the", "foo")));
    Query result = qp.parse("a:the OR a:foo");
    assertNotNull("result is null and it shouldn't be", result);
    assertTrue("result is not a BooleanQuery", result instanceof BooleanQuery);
    assertTrue(((BooleanQuery) result).clauses().size() + " does not equal: " + 0, ((BooleanQuery) result).clauses().size() == 0);
    result = qp.parse("a:woo OR a:the");
View Full Code Here

    if (VERBOSE) System.out.println("Result: " + result);
    assertTrue(((BooleanQuery) result).clauses().size() + " does not equal: " + 2, ((BooleanQuery) result).clauses().size() == 2);
  }

  public void testPositionIncrement() throws Exception {
    QueryParser qp = new QueryParser(TEST_VERSION_CURRENT, "a", new StopAnalyzer(TEST_VERSION_CURRENT, StopFilter.makeStopSet(TEST_VERSION_CURRENT, "the", "in", "are", "this")));
    qp.setEnablePositionIncrements(true);
    String qtxt = "\"the words in poisitions pos02578 are stopped in this phrasequery\"";
    //               0         2                      5           7  8
    int expectedPositions[] = {1,3,4,6,9};
    PhraseQuery pq = (PhraseQuery) qp.parse(qtxt);
View Full Code Here

//    Set stopWords = null;
    Set stopWords = StopFilter.makeStopSet(StopAnalyzer.ENGLISH_STOP_WORDS);
   
    Analyzer[] analyzers = new Analyzer[] {
        new SimpleAnalyzer(),
        new StopAnalyzer(),
        new StandardAnalyzer(),
        PatternAnalyzer.DEFAULT_ANALYZER,
//        new WhitespaceAnalyzer(),
//        new PatternAnalyzer(PatternAnalyzer.NON_WORD_PATTERN, false, null),
//        new PatternAnalyzer(PatternAnalyzer.NON_WORD_PATTERN, true, stopWords),       
View Full Code Here

     * Return default analyzer for application
     * A non-English site should use a different analyzer
     * @return default analyzer
    **/
    public static final Analyzer getAnalyzer() {
        return new StopAnalyzer();
    }
View Full Code Here

    assertEquals("slop of 6 just right", 1, hits.length());
  }
 
  public void testPhraseQueryWithStopAnalyzer() throws Exception {
    RAMDirectory directory = new RAMDirectory();
    StopAnalyzer stopAnalyzer = new StopAnalyzer();
    IndexWriter writer = new IndexWriter(directory, stopAnalyzer, true);
    Document doc = new Document();
    doc.add(new Field("field", "the stop words are here", Field.Store.YES, Field.Index.TOKENIZED));
    writer.addDocument(doc);
    writer.close();
View Full Code Here

     * Return default analyzer for application
     * A non-English site should use a different analyzer
     * @return default analyzer
    **/
    public static final Analyzer getAnalyzer() {
        return new StopAnalyzer();
    }
View Full Code Here

        task.setIndex(new File(indexDir));
        task.setProject(project);
        task.execute();

        searcher = new IndexSearcher(indexDir);
        analyzer = new StopAnalyzer();
    }
View Full Code Here

   */
  public void testList() throws Exception {
    FullTextSession s = Search.getFullTextSession( openSession() );
    createTestBooks(s);
    Transaction tx = s.beginTransaction();
    QueryParser parser = new QueryParser("title", new StopAnalyzer() );

    Query query = parser.parse( "summary:lucene" );
    FullTextQuery hibQuery = s.createFullTextQuery( query, Book.class );
    List<Book> result = hibQuery.list();
    assertNotNull( result );
View Full Code Here

    // need to sleep to give JMS processing and indexing time
    Thread.sleep( 1000 );

    FullTextSession ftSess = Search.getFullTextSession( openSession() );
    ftSess.getTransaction().begin();
    QueryParser parser = new QueryParser( "id", new StopAnalyzer() );
    Query luceneQuery = parser.parse( "logo:jboss" );
    org.hibernate.Query query = ftSess.createFullTextQuery( luceneQuery );
    List result = query.list();
    assertEquals( 1, result.size() );
    ftSess.delete( result.get( 0 ) );
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.