Package org.apache.lucene.index

Examples of org.apache.lucene.index.RandomIndexWriter.forceMerge()


    doc = new Document();
    doc.add(newStringField("id", "3", Field.Store.YES));
    doc.add(newTextField("body", "crappy contents", Field.Store.NO));
    doc.add(new NumericDocValuesField("popularity", 2));
    iw.addDocument(doc);
    iw.forceMerge(1);
   
    reader = iw.getReader();
    iw.close();
  }
 
View Full Code Here


      }
      doc.add(newStringField("field" + i, "content1", Field.Store.YES));
      w.addDocument(doc)
    }
   
    w.forceMerge(1);
    IndexReader reader = w.getReader();
    w.close();
    assertEquals(1, reader.leaves().size());
   
   
View Full Code Here

          terms.add(t);
          break;
        }
      }
    }
    w.forceMerge(1);
    IndexReader reader = w.getReader();
    w.close();
    assertEquals(1, reader.leaves().size());
    AtomicReaderContext context = reader.leaves().get(0);
    TermsFilter tf = new TermsFilter(new ArrayList<>(terms));
View Full Code Here

       *  need to force merge here since QueryUtils adds checks based
       *  on leave readers which have different statistics than the top
       *  level reader if we have more than one segment. This could
       *  result in a different query / results.
       */
      w.forceMerge(1);
      DirectoryReader reader2 = w.getReader();
      QueryUtils.check(random(), cq, newSearcher(reader2));
      reader2.close();
    } finally {
      reader.close();
View Full Code Here

      @SuppressWarnings("resource") RandomIndexWriter w =
          new RandomIndexWriter(random(), d);
      Document doc = new Document();
      doc.add(newField("ints", "1", StringField.TYPE_NOT_STORED));
      w.addDocument(doc);
      w.forceMerge(1);
      r = w.getReader();
      w.close();

      subR = r.leaves().get(0).reader();
    }
View Full Code Here

    doc.add(new TextField("price", "20.0", Field.Store.NO));
    doc.add(new TextField(idField, "6", Field.Store.NO));
    doc.add(new TextField(toField, "0", Field.Store.NO));
    w.addDocument(doc);

    w.forceMerge(1);

    IndexSearcher indexSearcher = new IndexSearcher(w.getReader());
    w.close();

    // Search for product
View Full Code Here

    }
    if (!doMultiSegment) {
      if (VERBOSE) {
        System.out.println("TEST: setUp full merge");
      }
      iw.forceMerge(1);
    }
    iw.close();
    if (VERBOSE) {
      System.out.println("TEST: setUp done close");
    }
View Full Code Here

      for (int f = 0; f < NUMBER_OF_FIELDS; f++) {
        document.add(newStringField("field" + f, getText(), Field.Store.NO));
      }
      writer.addDocument(document);
    }
    writer.forceMerge(1);
    writer.close();
  }

  private static String getText() {
    return Long.toString(random().nextLong(),Character.MAX_RADIX);
View Full Code Here

      Document doc = new Document();
      doc.add(newStringField("data", Integer.toString(i), Field.Store.NO));
      writer.addDocument(doc);
      ((i % 2 == 0) ? swriter1 : swriter2).addDocument(doc);
    }
    writer.forceMerge(1); swriter1.forceMerge(1); swriter2.forceMerge(1);
    writer.close(); swriter1.close(); swriter2.close();
   
    reader = DirectoryReader.open(dir);
    searcher = newSearcher(reader);
   
View Full Code Here

    Document childDoc = new Document();
    childDoc.add(newField("child", "2", Field.Store.NO, Field.Index.NOT_ANALYZED));
    w.addDocuments(Arrays.asList(childDoc, parentDoc));

    // Need single seg:
    w.forceMerge(1);
    IndexReader r = w.getReader();
    w.close();
    IndexSearcher s = newSearcher(r, false);
    Query tq = new TermQuery(new Term("child", "2"));
    final Filter parentsFilter = new CachingWrapperFilter(new RawTermFilter(new Term("isparent", "yes")),
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.