use of org.apache.lucene.document.SortedDocValuesField in project elasticsearch by elastic.
the class ParentFieldSubFetchPhaseTests method testGetParentIdNoParentField.
public void testGetParentIdNoParentField() throws Exception {
ParentFieldMapper fieldMapper = createParentFieldMapper();
Directory directory = newDirectory();
IndexWriter indexWriter = new IndexWriter(directory, newIndexWriterConfig());
Document document = new Document();
document.add(new SortedDocValuesField("different_field", new BytesRef("1")));
indexWriter.addDocument(document);
indexWriter.close();
IndexReader indexReader = DirectoryReader.open(directory);
String id = ParentFieldSubFetchPhase.getParentId(fieldMapper, indexReader.leaves().get(0).reader(), 0);
assertNull(id);
indexReader.close();
directory.close();
}
use of org.apache.lucene.document.SortedDocValuesField in project elasticsearch by elastic.
the class ValueCountAggregatorTests method testQueryFiltering.
public void testQueryFiltering() throws IOException {
testCase(IntPoint.newRangeQuery("level", 0, 5), ValueType.STRING, iw -> {
iw.addDocument(Arrays.asList(new IntPoint("level", 0), new SortedDocValuesField(FIELD_NAME, new BytesRef("foo"))));
iw.addDocument(Arrays.asList(new IntPoint("level", 1), new SortedDocValuesField(FIELD_NAME, new BytesRef("bar"))));
iw.addDocument(Arrays.asList(new IntPoint("level", 3), new SortedDocValuesField(FIELD_NAME, new BytesRef("foo"))));
iw.addDocument(Arrays.asList(new IntPoint("level", 5), new SortedDocValuesField(FIELD_NAME, new BytesRef("baz"))));
iw.addDocument(Arrays.asList(new IntPoint("level", 7), new SortedDocValuesField(FIELD_NAME, new BytesRef("baz"))));
}, count -> assertEquals(4L, count.getValue()));
}
use of org.apache.lucene.document.SortedDocValuesField in project elasticsearch by elastic.
the class ValueCountAggregatorTests method testQueryFiltersAll.
public void testQueryFiltersAll() throws IOException {
testCase(IntPoint.newRangeQuery("level", -1, 0), ValueType.STRING, iw -> {
iw.addDocument(Arrays.asList(new IntPoint("level", 3), new SortedDocValuesField(FIELD_NAME, new BytesRef("foo"))));
iw.addDocument(Arrays.asList(new IntPoint("level", 5), new SortedDocValuesField(FIELD_NAME, new BytesRef("baz"))));
}, count -> assertEquals(0L, count.getValue()));
}
use of org.apache.lucene.document.SortedDocValuesField in project lucene-solr by apache.
the class TestIndexWriter method testCloseWhileMergeIsRunning.
public void testCloseWhileMergeIsRunning() throws IOException {
Directory dir = newDirectory();
final CountDownLatch mergeStarted = new CountDownLatch(1);
final CountDownLatch closeStarted = new CountDownLatch(1);
IndexWriterConfig iwc = newIndexWriterConfig(random(), new MockAnalyzer(random())).setCommitOnClose(false);
LogDocMergePolicy mp = new LogDocMergePolicy();
mp.setMergeFactor(2);
iwc.setMergePolicy(mp);
iwc.setInfoStream(new InfoStream() {
@Override
public boolean isEnabled(String component) {
return true;
}
@Override
public void message(String component, String message) {
if (message.equals("rollback")) {
closeStarted.countDown();
}
}
@Override
public void close() {
}
});
iwc.setMergeScheduler(new ConcurrentMergeScheduler() {
@Override
public void doMerge(IndexWriter writer, MergePolicy.OneMerge merge) throws IOException {
mergeStarted.countDown();
try {
closeStarted.await();
} catch (InterruptedException ie) {
Thread.currentThread().interrupt();
throw new RuntimeException(ie);
}
super.doMerge(writer, merge);
}
@Override
public void close() {
}
});
IndexWriter w = new IndexWriter(dir, iwc);
Document doc = new Document();
doc.add(new SortedDocValuesField("dv", new BytesRef("foo!")));
w.addDocument(doc);
w.commit();
w.addDocument(doc);
w.commit();
w.close();
dir.close();
}
use of org.apache.lucene.document.SortedDocValuesField in project lucene-solr by apache.
the class TestIndexWriter method testDoubleClose.
public void testDoubleClose() throws IOException {
Directory dir = newDirectory();
IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(new MockAnalyzer(random())));
Document doc = new Document();
doc.add(new SortedDocValuesField("dv", new BytesRef("foo!")));
w.addDocument(doc);
w.close();
// Close again should have no effect
w.close();
dir.close();
}
Aggregations