Examples of SimpleAnalyzer


Examples of org.apache.lucene.analysis.SimpleAnalyzer

 
  // create an index of all the documents, or just the x, or just the y documents
  private Searcher getIndex (boolean even, boolean odd)
  throws IOException {
    RAMDirectory indexStore = new RAMDirectory ();
    IndexWriter writer = new IndexWriter (indexStore, new SimpleAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
    writer.setMaxBufferedDocs(2);
    writer.setMergeFactor(1000);
    for (int i=0; i<data.length; ++i) {
      if (((i%2)==0 && even) || ((i%2)==1 && odd)) {
        Document doc = new Document();
View Full Code Here

Examples of org.apache.lucene.analysis.SimpleAnalyzer

    return getIndex (true, true);
  }
 
  private IndexSearcher getFullStrings() throws CorruptIndexException, LockObtainFailedException, IOException {
    RAMDirectory indexStore = new RAMDirectory ();
    IndexWriter writer = new IndexWriter (indexStore, new SimpleAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
    writer.setMaxBufferedDocs(4);
    writer.setMergeFactor(97);
    for (int i=0; i<NUM_STRINGS; i++) {
        Document doc = new Document();
        String num = getRandomCharString(getRandomNumber(2, 8), 48, 52);
View Full Code Here

Examples of org.apache.lucene.analysis.SimpleAnalyzer

    }
  }

  public void testLUCENE2142() throws IOException {
    RAMDirectory indexStore = new RAMDirectory ();
    IndexWriter writer = new IndexWriter (indexStore, new SimpleAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
    for (int i=0; i<5; i++) {
        Document doc = new Document();
        doc.add (new Field ("string", "a"+i, Field.Store.NO, Field.Index.NOT_ANALYZED));
        doc.add (new Field ("string", "b"+i, Field.Store.NO, Field.Index.NOT_ANALYZED));
        writer.addDocument (doc);
View Full Code Here

Examples of org.apache.lucene.analysis.SimpleAnalyzer

  }

  // LUCENE-1442
  public void testDoubleOffsetCounting2() throws Exception {
    MockRAMDirectory dir = new MockRAMDirectory();
    IndexWriter w = new IndexWriter(dir, new SimpleAnalyzer(), IndexWriter.MaxFieldLength.LIMITED);
    Document doc = new Document();
    Field f = new Field("field", "abcd", Field.Store.NO, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS);
    doc.add(f);
    doc.add(f);
    w.addDocument(doc);
View Full Code Here

Examples of org.apache.lucene.analysis.SimpleAnalyzer

    d.close();
  }

  public void testNoDocsIndex() throws Throwable {
    Directory dir = new MockRAMDirectory();
    IndexWriter writer = new IndexWriter(dir, new SimpleAnalyzer(), IndexWriter.MaxFieldLength.UNLIMITED);
    writer.setUseCompoundFile(false);
    ByteArrayOutputStream bos = new ByteArrayOutputStream(1024);
    writer.setInfoStream(new PrintStream(bos));
    writer.addDocument(new Document());
    writer.close();
View Full Code Here

Examples of org.apache.lucene.analysis.SimpleAnalyzer

  // index
  public void testCommitThreadSafety() throws Throwable {
    final int NUM_THREADS = 5;
    final double RUN_SEC = 0.5;
    final Directory dir = new MockRAMDirectory();
    final IndexWriter w = new IndexWriter(dir, new SimpleAnalyzer(), IndexWriter.MaxFieldLength.UNLIMITED);
    w.commit();
    final List failed = Collections.synchronizedList(new ArrayList());
    Thread[] threads = new Thread[NUM_THREADS];
    final long endTime = System.currentTimeMillis()+((long) (RUN_SEC*1000));
    for(int i=0;i<NUM_THREADS;i++) {
View Full Code Here

Examples of org.apache.lucene.analysis.SimpleAnalyzer

import org.apache.lucene.util.LuceneTestCase;

public class TestNewestSegment extends LuceneTestCase {
  public void testNewestSegment() throws Exception {
    RAMDirectory directory = new RAMDirectory();
    IndexWriter writer = new IndexWriter(directory, new SimpleAnalyzer(), IndexWriter.MaxFieldLength.LIMITED);
    assertNull(writer.newestSegment());
  }
View Full Code Here

Examples of org.apache.lucene.analysis.SimpleAnalyzer

      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));
      indexWriter.addDocument(document, new SimpleAnalyzer());
      indexWriter.close();
    } catch(Exception ex) {
      ex.printStackTrace();
    } finally {
      if( indexFactory!=null ) {
View Full Code Here

Examples of org.apache.lucene.analysis.SimpleAnalyzer

  /*
   * Test for List search(QueryCreator, HitExtractor)
   */
  final public void testSearchQueryCreatorHitExtractor() throws Exception {
    Analyzer analyzer = new SimpleAnalyzer();
    MockControl searcherFactoryControl = MockControl.createStrictControl(SearcherFactory.class);
    SearcherFactory searcherFactory = (SearcherFactory)searcherFactoryControl.getMock();
    MockControl searcherControl = MockControl.createStrictControl(LuceneSearcher.class);
    LuceneSearcher searcher = (LuceneSearcher)searcherControl.getMock();
    MockControl queryCreatorControl = MockControl.createStrictControl(QueryCreator.class);
View Full Code Here

Examples of org.apache.lucene.analysis.SimpleAnalyzer

  /*
   * Test for List search(QueryCreator, HitExtractor) with ParsedQuery
   */
  final public void testSearchParsedQueryCreatorHitExtractor() throws Exception {
    Analyzer analyzer = new SimpleAnalyzer();
    MockControl searcherFactoryControl = MockControl.createStrictControl(SearcherFactory.class);
    SearcherFactory searcherFactory = (SearcherFactory)searcherFactoryControl.getMock();
    MockControl searcherControl = MockControl.createStrictControl(LuceneSearcher.class);
    LuceneSearcher searcher = (LuceneSearcher)searcherControl.getMock();
    MockControl hitsControl = MockControl.createStrictControl(LuceneHits.class);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.