Package org.apache.lucene.analysis

Examples of org.apache.lucene.analysis.SimpleAnalyzer


  }

  public void testAddDeleteDocumentError2() throws Exception {
    try {
      IndexReader reader = IndexReader.open(directory);
      IndexWriter writer = new IndexWriter(directory, new SimpleAnalyzer(), false);
   
      Document document = new Document();
      document.add(new Field("id", "1", Field.Store.YES, Field.Index.UN_TOKENIZED));
      document.add(new Field("field", "a sample", Field.Store.YES, Field.Index.TOKENIZED));
      document.add(new Field("filter", "a sample filter", Field.Store.YES, Field.Index.TOKENIZED));
View Full Code Here


  /*
   * Test for void index(String) with document handler registered
   */
  final public void testIndexStringDocumentHandler() throws Exception {
    SimpleAnalyzer analyzer = new SimpleAnalyzer();
    MockControl indexFactoryControl = MockControl.createStrictControl(IndexFactory.class);
    IndexFactory indexFactory = (IndexFactory)indexFactoryControl.getMock();
    MockControl indexWriterControl = MockControl.createStrictControl(LuceneIndexWriter.class);
    LuceneIndexWriter indexWriter = (LuceneIndexWriter)indexWriterControl.getMock();
    MockControl listenerControl = MockControl.createStrictControl(FileDocumentIndexingListener.class);
View Full Code Here

  /*
   * Test pour void index(String) with document handler registered
   */
  final public void testIndexStringListener() throws Exception {
    SimpleAnalyzer analyzer = new SimpleAnalyzer();
    MockControl indexFactoryControl = MockControl.createStrictControl(IndexFactory.class);
    IndexFactory indexFactory = (IndexFactory)indexFactoryControl.getMock();
    MockControl indexWriterControl = MockControl.createStrictControl(LuceneIndexWriter.class);
    LuceneIndexWriter indexWriter = (LuceneIndexWriter)indexWriterControl.getMock();
    MockControl listener1Control = MockControl.createStrictControl(FileDocumentIndexingListener.class);
View Full Code Here

      fail();
    } catch(IOException ex) {}
  }

  public void testAddDeleteDocumentSuccess() throws Exception {
    IndexWriter writer = new IndexWriter(directory, new SimpleAnalyzer(), false);
    Document document = new Document();
    document.add(new Field("id", "1", Field.Store.YES, Field.Index.UN_TOKENIZED));
    document.add(new Field("field", "a sample", Field.Store.YES, Field.Index.TOKENIZED));
    document.add(new Field("filter", "a sample filter", Field.Store.YES, Field.Index.TOKENIZED));
    document.add(new Field("sort", "2", Field.Store.YES, Field.Index.UN_TOKENIZED));
View Full Code Here

  /*
   * Test pour void index(String, boolean)
   */
  final public void testIndexStringboolean() throws Exception {
    SimpleAnalyzer analyzer = new SimpleAnalyzer();
    MockControl indexFactoryControl = MockControl.createNiceControl(IndexFactory.class);
    IndexFactory indexFactory = (IndexFactory)indexFactoryControl.getMock();
    MockControl indexWriterControl = MockControl.createNiceControl(LuceneIndexWriter.class);
    LuceneIndexWriter indexWriter = (LuceneIndexWriter)indexWriterControl.getMock();
    MockControl listenerControl = MockControl.createNiceControl(FileDocumentIndexingListener.class);
View Full Code Here

  /*
   * Test pour void index(String)
   */
  final public void testIndexStringIfDirectoryNotExist() throws Exception {
    SimpleAnalyzer analyzer = new SimpleAnalyzer();
    MockControl indexFactoryControl = MockControl.createControl(IndexFactory.class);
    IndexFactory indexFactory = (IndexFactory)indexFactoryControl.getMock();

    indexFactoryControl.replay();
   
View Full Code Here

    reader.deleteDocuments(new Term("field", "sample"));
    reader.close();
  }

  public void testAddOptimizeDocument() throws Exception {
    IndexWriter writer = new IndexWriter(directory, new SimpleAnalyzer(), false);
    Document document = new Document();
    document.add(new Field("id", "1", Field.Store.YES, Field.Index.UN_TOKENIZED));
    document.add(new Field("field", "a sample", Field.Store.YES, Field.Index.TOKENIZED));
    document.add(new Field("filter", "a sample filter", Field.Store.YES, Field.Index.TOKENIZED));
    document.add(new Field("sort", "2", Field.Store.YES, Field.Index.UN_TOKENIZED));
View Full Code Here

    writer.close();
  }

  public void testDeleteOptimizeDocumentError1() throws Exception {
    try {
      IndexWriter writer = new IndexWriter(directory, new SimpleAnalyzer(), false);
      IndexReader reader = IndexReader.open(directory);
      reader.deleteDocuments(new Term("field", "sample"));
      writer.optimize();
     
      fail();
View Full Code Here

    } catch (Exception ex) { }
  }

  public void testDeleteOptimizeDocumentError2() throws Exception {
    try {
      IndexWriter writer = new IndexWriter(directory, new SimpleAnalyzer(), false);
      IndexReader reader = IndexReader.open(directory);
      reader.deleteDocuments(new Term("field", "sample"));
      reader.close();
      writer.optimize();
      writer.close();
View Full Code Here

  public void testDeleteOptimizeDocumentSucess() throws Exception {
    IndexReader reader = IndexReader.open(directory);
    reader.deleteDocuments(new Term("field", "sample"));
    reader.close();

    IndexWriter writer = new IndexWriter(directory, new SimpleAnalyzer(), false);
    writer.optimize();
    writer.close();
  }
View Full Code Here

TOP

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

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.