Package org.springmodules.lucene.index.core

Examples of org.springmodules.lucene.index.core.DefaultLuceneIndexTemplate


  public void testTemplateExecutionWithIndexReader() throws Exception {
    IndexFactory indexFactory = createIndexFactory();
    ResourceManager resourceManager = createResourceManager(indexFactory);
   
    DefaultLuceneIndexTemplate template = new DefaultLuceneIndexTemplate();
    template.setIndexFactory(indexFactory);
    template.setAnalyzer(new SimpleAnalyzer());
    template.afterPropertiesSet();

    DefaultResourceManagementDefinition definition = new DefaultResourceManagementDefinition();
    definition.setIndexReaderOpen(true);
    definition.setWriteOperationsForIndexReaderAuthorized(true);
    try {
      resourceManager.initializeResources(definition);
     
      template.deleteDocuments(new Term("id", "1"));
      template.hasDeletions();
      template.isDeleted(1);
      template.isDeleted(2);
      template.undeleteDocuments();
    } finally {
      resourceManager.releaseResources();
    }
  }
View Full Code Here


  public void testTemplateExecutionWithIndexWriter() throws Exception {
    IndexFactory indexFactory = createIndexFactory();
    ResourceManager resourceManager = createResourceManager(indexFactory);
   
    DefaultLuceneIndexTemplate template = new DefaultLuceneIndexTemplate();
    template.setIndexFactory(indexFactory);
    template.setAnalyzer(new SimpleAnalyzer());
    template.afterPropertiesSet();

    DefaultResourceManagementDefinition definition = new DefaultResourceManagementDefinition();
    definition.setIndexWriterOpen(true);
    definition.setWriteOperationsForIndexWriterAuthorized(true);
    try {
      resourceManager.initializeResources(definition);
     
      Document document = new Document();
      document.add(new Field("id", "1", Field.Store.YES, Field.Index.UN_TOKENIZED));
      template.addDocument(document);
      template.addDocument(document);
      template.addDocument(document);
      template.optimize();
    } finally {
      resourceManager.releaseResources();
    }
  }
View Full Code Here

  public void testTemplateExecutionWithIndexWriterReaderWithError() throws Exception {
    IndexFactory indexFactory = createIndexFactory();
    ResourceManager resourceManager = createResourceManager(indexFactory);
   
    DefaultLuceneIndexTemplate template = new DefaultLuceneIndexTemplate();
    template.setIndexFactory(indexFactory);
    template.setAnalyzer(new SimpleAnalyzer());
    template.afterPropertiesSet();

    DefaultResourceManagementDefinition definition = new DefaultResourceManagementDefinition();
    definition.setIndexWriterOpen(true);
    definition.setWriteOperationsForIndexWriterAuthorized(true);
    //definition.setIndexReaderOpen(true);
    definition.setWriteOperationsForIndexReaderAuthorized(false);
    try {
      resourceManager.initializeResources(definition);
     
      Document document = new Document();
      document.add(new Field("id", "3", Field.Store.YES, Field.Index.UN_TOKENIZED));
      template.addDocument(document);
      template.addDocument(document);
      template.addDocument(document);
      try {
        template.deleteDocuments(new Term("id", "1"));
        fail();
      } catch(LuceneIndexingException ex) {}
      template.optimize();
    } finally {
      resourceManager.releaseResources();
    }
  }
View Full Code Here

  public void testTemplateExecutionWithIndexWriterReader() throws Exception {
    IndexFactory indexFactory = createIndexFactory();
    ResourceManager resourceManager = createResourceManager(indexFactory);
   
    DefaultLuceneIndexTemplate template = new DefaultLuceneIndexTemplate();
    template.setIndexFactory(indexFactory);
    template.setAnalyzer(new SimpleAnalyzer());
    template.afterPropertiesSet();

    DefaultResourceManagementDefinition definition = new DefaultResourceManagementDefinition();
    definition.setIndexWriterOpen(true);
    definition.setWriteOperationsForIndexWriterAuthorized(true);
    definition.setIndexReaderOpen(true);
    definition.setWriteOperationsForIndexReaderAuthorized(false);
    try {
      resourceManager.initializeResources(definition);
     
      Document document = new Document();
      document.add(new Field("id", "3", Field.Store.YES, Field.Index.UN_TOKENIZED));
      template.addDocument(document);
      template.addDocument(document);
      template.addDocument(document);
      try {
        template.deleteDocuments(new Term("id", "1"));
      } catch(LuceneIndexingException ex) {}
      template.optimize();
    } finally {
      resourceManager.releaseResources();
    }
  }
View Full Code Here

    if( this.template==null && this.indexFactory==null ) {
      throw new BeanInitializationException("indexFactory property required");
    }

    if( this.template==null ) {
      this.template=new DefaultLuceneIndexTemplate(indexFactory,analyzer);
    }
  }
View Full Code Here

    if( this.template==null ) {
      if( this.indexFactory==null ) {
        throw new BeanInitializationException("indexFactory property required");
      }

      this.template = new DefaultLuceneIndexTemplate(indexFactory, analyzer);
    }
  }
View Full Code Here

TOP

Related Classes of org.springmodules.lucene.index.core.DefaultLuceneIndexTemplate

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.