use of org.apache.lucene.document.SortedDocValuesField in project lucene-solr by apache.
the class TestDocValuesIndexing method testMixedTypesDifferentThreads.
// Two documents with same field as different types, added
// from separate threads:
public void testMixedTypesDifferentThreads() throws Exception {
Directory dir = newDirectory();
final IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(new MockAnalyzer(random())));
final CountDownLatch startingGun = new CountDownLatch(1);
final AtomicBoolean hitExc = new AtomicBoolean();
Thread[] threads = new Thread[3];
for (int i = 0; i < 3; i++) {
Field field;
if (i == 0) {
field = new SortedDocValuesField("foo", new BytesRef("hello"));
} else if (i == 1) {
field = new NumericDocValuesField("foo", 0);
} else {
field = new BinaryDocValuesField("foo", new BytesRef("bazz"));
}
final Document doc = new Document();
doc.add(field);
threads[i] = new Thread() {
@Override
public void run() {
try {
startingGun.await();
w.addDocument(doc);
} catch (IllegalArgumentException iae) {
// expected
hitExc.set(true);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
};
threads[i].start();
}
startingGun.countDown();
for (Thread t : threads) {
t.join();
}
assertTrue(hitExc.get());
w.close();
dir.close();
}
use of org.apache.lucene.document.SortedDocValuesField in project lucene-solr by apache.
the class TestDocValuesIndexing method testTypeChangeAfterDeleteAll.
public void testTypeChangeAfterDeleteAll() throws Exception {
Directory dir = newDirectory();
IndexWriterConfig conf = newIndexWriterConfig(new MockAnalyzer(random()));
IndexWriter writer = new IndexWriter(dir, conf);
Document doc = new Document();
doc.add(new NumericDocValuesField("dv", 0L));
writer.addDocument(doc);
writer.deleteAll();
doc = new Document();
doc.add(new SortedDocValuesField("dv", new BytesRef("foo")));
writer.addDocument(doc);
writer.close();
dir.close();
}
use of org.apache.lucene.document.SortedDocValuesField in project lucene-solr by apache.
the class TestDocValuesIndexing method testMixedTypesAfterReopenAppend1.
public void testMixedTypesAfterReopenAppend1() throws Exception {
Directory dir = newDirectory();
IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(new MockAnalyzer(random())));
Document doc = new Document();
doc.add(new NumericDocValuesField("foo", 0));
w.addDocument(doc);
w.close();
IndexWriter w2 = new IndexWriter(dir, newIndexWriterConfig(new MockAnalyzer(random())));
Document doc2 = new Document();
doc2.add(new SortedDocValuesField("foo", new BytesRef("hello")));
expectThrows(IllegalArgumentException.class, () -> {
w2.addDocument(doc2);
});
w2.close();
dir.close();
}
use of org.apache.lucene.document.SortedDocValuesField in project lucene-solr by apache.
the class TestDocValuesIndexing method testTypeChangeAfterCloseAndDeleteAll.
public void testTypeChangeAfterCloseAndDeleteAll() throws Exception {
Directory dir = newDirectory();
IndexWriterConfig conf = newIndexWriterConfig(new MockAnalyzer(random()));
IndexWriter writer = new IndexWriter(dir, conf);
Document doc = new Document();
doc.add(new NumericDocValuesField("dv", 0L));
writer.addDocument(doc);
writer.close();
conf = newIndexWriterConfig(new MockAnalyzer(random()));
writer = new IndexWriter(dir, conf);
writer.deleteAll();
doc = new Document();
doc.add(new SortedDocValuesField("dv", new BytesRef("foo")));
writer.addDocument(doc);
writer.close();
dir.close();
}
use of org.apache.lucene.document.SortedDocValuesField in project lucene-solr by apache.
the class TestDocValuesIndexing method testMixedTypesAfterDeleteAll.
// Add inconsistent document after deleteAll
public void testMixedTypesAfterDeleteAll() throws Exception {
Directory dir = newDirectory();
IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(new MockAnalyzer(random())));
Document doc = new Document();
doc.add(new NumericDocValuesField("foo", 0));
w.addDocument(doc);
w.deleteAll();
doc = new Document();
doc.add(new SortedDocValuesField("foo", new BytesRef("hello")));
w.addDocument(doc);
w.close();
dir.close();
}
Aggregations