s1monw commented on code in PR #12829:
URL: https://github.com/apache/lucene/pull/12829#discussion_r1403174609
##########
lucene/core/src/test/org/apache/lucene/index/TestIndexSorting.java:
##########
@@ -3173,4 +3173,184 @@ public void
testSortDocsAndFreqsAndPositionsAndOffsets() throws IOException {
reader.close();
dir.close();
}
+
+ public void testBlockIsMissingParentField() throws IOException {
+ try (Directory dir = newDirectory()) {
+ IndexWriterConfig iwc = new IndexWriterConfig(new
MockAnalyzer(random()));
+ String parentField = "parent";
+ Sort indexSort = new Sort(parentField, new SortField("foo",
SortField.Type.INT));
+ iwc.setIndexSort(indexSort);
+ try (IndexWriter writer = new IndexWriter(dir, iwc)) {
+ List<Runnable> runnabels =
+ Arrays.asList(
+ () -> {
+ IllegalArgumentException ex =
+ expectThrows(
+ IllegalArgumentException.class,
+ () -> {
+ writer.addDocuments(Arrays.asList(new Document(),
new Document()));
+ });
+ assertEquals(
+ "the last document in the block must contain a numeric
doc values field named: parent",
+ ex.getMessage());
+ },
+ () -> {
+ IllegalArgumentException ex =
+ expectThrows(
+ IllegalArgumentException.class,
+ () -> {
+ Document doc = new Document();
+ doc.add(new NumericDocValuesField("parent", 0));
+ writer.addDocuments(Arrays.asList(doc, new
Document()));
+ });
+ assertEquals(
+ "only the last document in the block must contain a
numeric doc values field named: parent",
Review Comment:
I am not sure what the semantics of this would be. I think we should not
violate the semantics of the `addDocuments` API that guarantees the insert
order being preserved across merges etc. from that perspective I think it's
actually good that we don't do that?
Also if you rely on a certain order you should sort it ahead of time or at
retrieval time.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]