You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by "s1monw (via GitHub)" <gi...@apache.org> on 2023/11/21 10:41:53 UTC
[PR] Add support for index sorting with document blocks [lucene]
s1monw opened a new pull request, #12829:
URL: https://github.com/apache/lucene/pull/12829
Today index sorting with likely break document blocks added with `IndexWriter#addDocuments(...)` and friends since the index sorter has no indication of what documents are part of a block. This change proposes a marker field as a requirement for parent documents if the block API is used in conjunction with index sorting.
At this point this change requires a `NumericDV` field only present on the last document of a block or on every document indexed as an individual document iff a parent field is configured on the Sort. This can potentially be extended to a `Term` which is not as straight forward since validations might be more difficult and today postings are not available when we sort the flushed segment.
Relates to #12711
--
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: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Add support for index sorting with document blocks [lucene]
Posted by "mikemccand (via GitHub)" <gi...@apache.org>.
mikemccand commented on code in PR #12829:
URL: https://github.com/apache/lucene/pull/12829#discussion_r1406124683
##########
lucene/core/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java:
##########
@@ -262,6 +277,73 @@ long updateDocuments(
}
}
+ private interface DocValidator extends Consumer<IndexableField> {
Review Comment:
Do we really need a new interface here? We have only one validator now (`ParentBlockValidator`) -- can we just make a concrete instance of that which IW calls?
##########
lucene/core/src/java/org/apache/lucene/search/Sort.java:
##########
@@ -59,10 +61,28 @@ public Sort() {
* is still a tie after all SortFields are checked, the internal Lucene docid is used to break it.
*/
public Sort(SortField... fields) {
+ this(null, fields);
+ }
+
+ /**
+ * Sets the sort to the given criteria in succession: the first SortField is checked first, but if
+ * it produces a tie, then the second SortField is used to break the tie, etc. Finally, if there
+ * is still a tie after all SortFields are checked, the internal Lucene docid is used to break it.
+ *
+ * @param parentField the name of a numeric doc values field that marks the last document of a
+ * document blocks indexed with {@link
+ * org.apache.lucene.index.IndexWriter#addDocuments(Iterable)} or it's update relatives. This
+ * is required for indices that use index sorting in combination with document blocks in order
+ * to maintain the document order of the blocks documents. Index sorting will effectively
+ * compare the parent (last document) of a block in order to stable sort all it's adjacent
Review Comment:
s/it's/its
##########
lucene/core/src/java/org/apache/lucene/search/Sort.java:
##########
@@ -59,10 +61,28 @@ public Sort() {
* is still a tie after all SortFields are checked, the internal Lucene docid is used to break it.
*/
public Sort(SortField... fields) {
+ this(null, fields);
+ }
+
+ /**
+ * Sets the sort to the given criteria in succession: the first SortField is checked first, but if
+ * it produces a tie, then the second SortField is used to break the tie, etc. Finally, if there
+ * is still a tie after all SortFields are checked, the internal Lucene docid is used to break it.
+ *
+ * @param parentField the name of a numeric doc values field that marks the last document of a
Review Comment:
Can we make it clearer that you only use this for index-time sorting? It has no meaning at search time (and should not be set)?
Or ... does it have search-time meaning? Can I use this to retrieve whole blocks in my search hits?
##########
lucene/core/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java:
##########
@@ -262,6 +277,73 @@ long updateDocuments(
}
}
+ private interface DocValidator extends Consumer<IndexableField> {
+
+ default void afterDocument() {}
+
+ default void beforeDocument() {}
+
+ default void afterDocuments(int numDocs) {}
+
+ default void reset() {}
+ }
+
+ private static class ParentBlockValidator implements DocValidator {
+ private boolean lastDocHasParentField = false;
Review Comment:
You don't need the `= false` -- it's java's default already :)
##########
lucene/core/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java:
##########
@@ -262,6 +277,73 @@ long updateDocuments(
}
}
+ private interface DocValidator extends Consumer<IndexableField> {
+
+ default void afterDocument() {}
+
+ default void beforeDocument() {}
+
+ default void afterDocuments(int numDocs) {}
+
+ default void reset() {}
+ }
+
+ private static class ParentBlockValidator implements DocValidator {
+ private boolean lastDocHasParentField = false;
+ private boolean childDocHasParentField = false;
+ private final String parentFieldName;
+
+ @Override
+ public void reset() {
+ lastDocHasParentField = false;
+ childDocHasParentField = false;
+ }
+
+ private ParentBlockValidator(Sort sort) {
+ this.parentFieldName = sort.getParentField();
+ }
+
+ @Override
+ public void beforeDocument() {
+ if (childDocHasParentField == false && lastDocHasParentField) {
+ childDocHasParentField = true;
+ }
+ lastDocHasParentField = false;
+ }
+
+ @Override
+ public void accept(IndexableField field) {
+ if (parentFieldName != null) {
+ if (parentFieldName.equals(field.name())
+ && DocValuesType.NUMERIC == field.fieldType().docValuesType()) {
+ lastDocHasParentField = true;
+ }
+ }
+ }
+
+ @Override
+ public void afterDocument() {
+ if (childDocHasParentField) {
+ throw new IllegalArgumentException(
+ "only the last document in the block must contain a numeric doc values field named: "
Review Comment:
Maybe reword to `"child documents must not contain the parent doc values field \"" + parentFieldName + "\""` or so?
##########
lucene/core/src/java/org/apache/lucene/search/Sort.java:
##########
@@ -59,10 +61,28 @@ public Sort() {
* is still a tie after all SortFields are checked, the internal Lucene docid is used to break it.
*/
public Sort(SortField... fields) {
+ this(null, fields);
+ }
+
+ /**
+ * Sets the sort to the given criteria in succession: the first SortField is checked first, but if
+ * it produces a tie, then the second SortField is used to break the tie, etc. Finally, if there
+ * is still a tie after all SortFields are checked, the internal Lucene docid is used to break it.
+ *
+ * @param parentField the name of a numeric doc values field that marks the last document of a
+ * document blocks indexed with {@link
+ * org.apache.lucene.index.IndexWriter#addDocuments(Iterable)} or it's update relatives. This
+ * is required for indices that use index sorting in combination with document blocks in order
+ * to maintain the document order of the blocks documents. Index sorting will effectively
+ * compare the parent (last document) of a block in order to stable sort all it's adjacent
+ * documents that belong to a block. This field must be a numeric doc values field a
+ */
+ public Sort(String parentField, SortField... fields) {
Review Comment:
It's sort of strange that we are pushing this down into `Sort` since when used at search time (for sorting hits) a `parentField` doesn't make sense?
Do we check that `parentField` is not specified when sorting hits during searching?
##########
lucene/core/src/java/org/apache/lucene/search/Sort.java:
##########
@@ -85,7 +110,7 @@ public SortField[] getSort() {
*/
public Sort rewrite(IndexSearcher searcher) throws IOException {
boolean changed = false;
-
+ assert parentField == null;
Review Comment:
Ahh we do here -- maybe make this a real `if` since a user might incorrectly set a `parentField` hoping for something to happen.
##########
lucene/core/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java:
##########
@@ -262,6 +277,73 @@ long updateDocuments(
}
}
+ private interface DocValidator extends Consumer<IndexableField> {
+
+ default void afterDocument() {}
+
+ default void beforeDocument() {}
+
+ default void afterDocuments(int numDocs) {}
+
+ default void reset() {}
+ }
+
+ private static class ParentBlockValidator implements DocValidator {
+ private boolean lastDocHasParentField = false;
+ private boolean childDocHasParentField = false;
+ private final String parentFieldName;
+
+ @Override
+ public void reset() {
+ lastDocHasParentField = false;
+ childDocHasParentField = false;
+ }
+
+ private ParentBlockValidator(Sort sort) {
+ this.parentFieldName = sort.getParentField();
+ }
+
+ @Override
+ public void beforeDocument() {
+ if (childDocHasParentField == false && lastDocHasParentField) {
+ childDocHasParentField = true;
+ }
+ lastDocHasParentField = false;
+ }
+
+ @Override
+ public void accept(IndexableField field) {
+ if (parentFieldName != null) {
+ if (parentFieldName.equals(field.name())
+ && DocValuesType.NUMERIC == field.fieldType().docValuesType()) {
+ lastDocHasParentField = true;
+ }
+ }
+ }
+
+ @Override
+ public void afterDocument() {
+ if (childDocHasParentField) {
+ throw new IllegalArgumentException(
+ "only the last document in the block must contain a numeric doc values field named: "
+ + parentFieldName);
+ }
+ }
+
+ @Override
+ public void afterDocuments(int numDocs) {
+ if (numDocs > 1 && parentFieldName == null) {
+ throw new IllegalArgumentException(
+ "A parent field must be set in order to use document blocks with index sorting");
+ }
+ if (parentFieldName != null && lastDocHasParentField == false) {
+ throw new IllegalArgumentException(
+ "the last document in the block must contain a numeric doc values field named: "
Review Comment:
Maybe `must contain the parent doc values field`?
##########
lucene/core/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java:
##########
@@ -262,6 +277,73 @@ long updateDocuments(
}
}
+ private interface DocValidator extends Consumer<IndexableField> {
+
+ default void afterDocument() {}
+
+ default void beforeDocument() {}
+
+ default void afterDocuments(int numDocs) {}
+
+ default void reset() {}
+ }
+
+ private static class ParentBlockValidator implements DocValidator {
+ private boolean lastDocHasParentField = false;
+ private boolean childDocHasParentField = false;
+ private final String parentFieldName;
+
+ @Override
+ public void reset() {
+ lastDocHasParentField = false;
+ childDocHasParentField = false;
+ }
+
+ private ParentBlockValidator(Sort sort) {
+ this.parentFieldName = sort.getParentField();
+ }
+
+ @Override
+ public void beforeDocument() {
+ if (childDocHasParentField == false && lastDocHasParentField) {
+ childDocHasParentField = true;
+ }
+ lastDocHasParentField = false;
+ }
+
+ @Override
+ public void accept(IndexableField field) {
+ if (parentFieldName != null) {
+ if (parentFieldName.equals(field.name())
+ && DocValuesType.NUMERIC == field.fieldType().docValuesType()) {
+ lastDocHasParentField = true;
+ }
+ }
+ }
+
+ @Override
+ public void afterDocument() {
+ if (childDocHasParentField) {
+ throw new IllegalArgumentException(
+ "only the last document in the block must contain a numeric doc values field named: "
+ + parentFieldName);
+ }
+ }
+
+ @Override
+ public void afterDocuments(int numDocs) {
+ if (numDocs > 1 && parentFieldName == null) {
+ throw new IllegalArgumentException(
+ "A parent field must be set in order to use document blocks with index sorting");
Review Comment:
Lowercase `a` for consistency? And maybe point to `Sort.setParentField` or so?
##########
lucene/core/src/java/org/apache/lucene/search/Sort.java:
##########
@@ -59,10 +61,28 @@ public Sort() {
* is still a tie after all SortFields are checked, the internal Lucene docid is used to break it.
*/
public Sort(SortField... fields) {
+ this(null, fields);
+ }
+
+ /**
+ * Sets the sort to the given criteria in succession: the first SortField is checked first, but if
+ * it produces a tie, then the second SortField is used to break the tie, etc. Finally, if there
+ * is still a tie after all SortFields are checked, the internal Lucene docid is used to break it.
+ *
+ * @param parentField the name of a numeric doc values field that marks the last document of a
+ * document blocks indexed with {@link
+ * org.apache.lucene.index.IndexWriter#addDocuments(Iterable)} or it's update relatives. This
+ * is required for indices that use index sorting in combination with document blocks in order
+ * to maintain the document order of the blocks documents. Index sorting will effectively
Review Comment:
Does this mean the Sort is otherwise free to break up the block? I.e. this `parentField` will override sort fields that might attempt to sort child docs away from one another?
##########
lucene/core/src/java/org/apache/lucene/search/Sort.java:
##########
@@ -59,10 +61,28 @@ public Sort() {
* is still a tie after all SortFields are checked, the internal Lucene docid is used to break it.
*/
public Sort(SortField... fields) {
+ this(null, fields);
+ }
+
+ /**
+ * Sets the sort to the given criteria in succession: the first SortField is checked first, but if
+ * it produces a tie, then the second SortField is used to break the tie, etc. Finally, if there
+ * is still a tie after all SortFields are checked, the internal Lucene docid is used to break it.
+ *
+ * @param parentField the name of a numeric doc values field that marks the last document of a
+ * document blocks indexed with {@link
+ * org.apache.lucene.index.IndexWriter#addDocuments(Iterable)} or it's update relatives. This
+ * is required for indices that use index sorting in combination with document blocks in order
+ * to maintain the document order of the blocks documents. Index sorting will effectively
+ * compare the parent (last document) of a block in order to stable sort all it's adjacent
+ * documents that belong to a block. This field must be a numeric doc values field a
Review Comment:
Remove that errant last `a` and replace with a period maybe?
##########
lucene/core/src/java/org/apache/lucene/search/Sort.java:
##########
@@ -59,10 +61,28 @@ public Sort() {
* is still a tie after all SortFields are checked, the internal Lucene docid is used to break it.
*/
public Sort(SortField... fields) {
+ this(null, fields);
+ }
+
+ /**
+ * Sets the sort to the given criteria in succession: the first SortField is checked first, but if
+ * it produces a tie, then the second SortField is used to break the tie, etc. Finally, if there
+ * is still a tie after all SortFields are checked, the internal Lucene docid is used to break it.
+ *
+ * @param parentField the name of a numeric doc values field that marks the last document of a
+ * document blocks indexed with {@link
+ * org.apache.lucene.index.IndexWriter#addDocuments(Iterable)} or it's update relatives. This
Review Comment:
s/it's/its
##########
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:
@msokolov I think multiple joins (nested levels) would work, except the user cannot use this parent DV field to record the sub-structure? Another field must be added by the user to record the child -> grandchild blocks. I agree it'd be nice if this parent field would accommodate more than one level of nesting, but maybe that can be a followon improvement.
This field would only handle a single level (the entire block of child and grandchild docs).
--
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: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Add support for index sorting with document blocks [lucene]
Posted by "s1monw (via GitHub)" <gi...@apache.org>.
s1monw commented on code in PR #12829:
URL: https://github.com/apache/lucene/pull/12829#discussion_r1434195239
##########
lucene/core/src/java/org/apache/lucene/index/IndexingChain.java:
##########
@@ -219,15 +224,41 @@ private Sorter.DocMap maybeSortSegment(SegmentWriteState state) throws IOExcepti
}
LeafReader docValuesReader = getDocValuesLeafReader();
-
+ Function<IndexSorter.DocComparator, IndexSorter.DocComparator> comparatorWrapper = in -> in;
+
+ if (state.segmentInfo.getHasBlocks() && state.fieldInfos.getParentField() != null) {
+ final DocIdSetIterator readerValues =
+ docValuesReader.getNumericDocValues(state.fieldInfos.getParentField());
+ if (readerValues == null) {
+ throw new CorruptIndexException(
+ "missing doc values for parent field \"" + state.fieldInfos.getParentField() + "\"",
+ "IndexingChain");
+ }
+ BitSet parents = BitSet.of(readerValues, state.segmentInfo.maxDoc());
+ comparatorWrapper =
+ in ->
+ (docID1, docID2) ->
+ in.compare(parents.nextSetBit(docID1), parents.nextSetBit(docID2));
+ }
+ if (state.segmentInfo.getHasBlocks()
+ && state.fieldInfos.getParentField() == null
+ && indexCreatedVersionMajor >= Version.LUCENE_10_0_0.major) {
+ throw new CorruptIndexException(
+ "parent field is not set but the index has blocks. indexCreatedVersionMajor: "
+ + indexCreatedVersionMajor,
+ "IndexingChain");
Review Comment:
Oh yeah but this check only happens when you use sorting... I will fix the wording
--
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: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Add support for index sorting with document blocks [lucene]
Posted by "mikemccand (via GitHub)" <gi...@apache.org>.
mikemccand commented on code in PR #12829:
URL: https://github.com/apache/lucene/pull/12829#discussion_r1440776102
##########
lucene/core/src/java/org/apache/lucene/index/FieldInfos.java:
##########
@@ -437,6 +488,33 @@ private void verifySoftDeletedFieldName(String fieldName, boolean isSoftDeletesF
}
}
+ private void verifyParentFieldName(String fieldName, boolean isParentField) {
+ if (isParentField) {
+ if (parentFieldName == null) {
+ throw new IllegalArgumentException(
+ "this index has ["
+ + fieldName
+ + "] as parent document field already but parent document field is not configured in IWC");
+ } else if (fieldName.equals(parentFieldName) == false) {
+ throw new IllegalArgumentException(
+ "cannot configure ["
+ + parentFieldName
+ + "] as parent document field ; this index uses ["
+ + fieldName
Review Comment:
OK I am still confused here -- this looks backwards to me (`fieldName` and `parentFieldName` should be swapped)?
I.e. `parentFieldName` was derived from the index as the already established parent field, and now a newly indexed document / current IWC is attempting to set `fieldName` as the parent field?
--
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: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Add support for index sorting with document blocks [lucene]
Posted by "s1monw (via GitHub)" <gi...@apache.org>.
s1monw merged PR #12829:
URL: https://github.com/apache/lucene/pull/12829
--
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: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Add support for index sorting with document blocks [lucene]
Posted by "mikemccand (via GitHub)" <gi...@apache.org>.
mikemccand commented on code in PR #12829:
URL: https://github.com/apache/lucene/pull/12829#discussion_r1435648884
##########
lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextSegmentInfoFormat.java:
##########
@@ -197,7 +197,13 @@ public SegmentInfo read(
sortField[i] = SortFieldProvider.forName(provider).readSortField(bytes);
assert bytes.eof();
}
- Sort indexSort = sortField.length == 0 ? null : new Sort(sortField);
+
+ final Sort indexSort;
+ if (sortField.length == 0) {
Review Comment:
Thank you! Die ternary operator die!
##########
lucene/core/src/java/org/apache/lucene/index/FieldInfos.java:
##########
@@ -437,6 +486,31 @@ private void verifySoftDeletedFieldName(String fieldName, boolean isSoftDeletesF
}
}
+ private void verifyParentFieldName(String fieldName, boolean isParentField) {
+ if (isParentField) {
+ if (parentFieldName == null) {
+ throw new IllegalArgumentException(
+ "this index has ["
+ + fieldName
+ + "] as parent document field already but parent document field is not configured in IWC");
+ } else if (fieldName.equals(parentFieldName) == false) {
+ throw new IllegalArgumentException(
+ "cannot configure ["
+ + parentFieldName
+ + "] as parent document field ; this index uses ["
+ + fieldName
+ + "] as parent document field already");
+ }
+ } else if (fieldName.equals(parentFieldName)) {
+ throw new IllegalArgumentException(
+ "cannot configure ["
+ + parentFieldName
+ + "] as parent document field ; this index uses ["
Review Comment:
Hmm isn't this exception message wrong? It should be more like "this index has <parentFieldName> as parent field already, cannot index this as non-parent field now" or so?
##########
lucene/core/src/java/org/apache/lucene/index/FieldInfos.java:
##########
@@ -132,6 +135,13 @@ public FieldInfos(FieldInfo[] infos) {
}
softDeletesField = info.name;
}
+ if (info.isParentField()) {
+ if (parentField != null && parentField.equals(info.name) == false) {
+ throw new IllegalArgumentException(
+ "multiple parent fields [" + info.name + ", " + parentField + "]");
Review Comment:
Maybe clarify for the user something like `only a single parent field is allowed: saw both "X" and "Y"` or so?
##########
lucene/core/src/java/org/apache/lucene/index/FieldInfos.java:
##########
@@ -355,11 +395,19 @@ static final class FieldNumbers {
this.omitNorms = new HashMap<>();
this.storeTermVectors = new HashMap<>();
this.softDeletesFieldName = softDeletesFieldName;
+ this.parentFieldName = parentFieldName;
+ if (softDeletesFieldName != null
+ && parentFieldName != null
+ && parentFieldName.equals(softDeletesFieldName)) {
+ throw new IllegalArgumentException(
+ "parent document and soft-deletes field can't be the same field");
Review Comment:
Include the field name in the exception message?
##########
lucene/core/src/java/org/apache/lucene/index/FieldInfos.java:
##########
@@ -78,6 +80,7 @@ public FieldInfos(FieldInfo[] infos) {
boolean hasPointValues = false;
boolean hasVectorValues = false;
String softDeletesField = null;
+ String parentField = null;
Review Comment:
We should remove all these (pointless) initializers since they are already javac's default? Or it's OK for a "when in Rome..." situation...
##########
lucene/core/src/java/org/apache/lucene/index/FieldInfo.java:
##########
@@ -206,6 +210,13 @@ public void checkConsistency() {
throw new IllegalArgumentException(
"vectorDimension must be >=0; got " + vectorDimension + " (field: '" + name + "')");
}
+
+ if (softDeletesField && parentField) {
+ throw new IllegalArgumentException(
+ "field can't be used as soft-deletes field and parent document field (field: '"
Review Comment:
Whoa, sneaky!
##########
lucene/core/src/java/org/apache/lucene/codecs/lucene94/Lucene94FieldInfosFormat.java:
##########
@@ -157,6 +158,13 @@ public FieldInfos read(
boolean omitNorms = (bits & OMIT_NORMS) != 0;
boolean storePayloads = (bits & STORE_PAYLOADS) != 0;
boolean isSoftDeletesField = (bits & SOFT_DELETES_FIELD) != 0;
+ boolean isParentField =
+ format >= FORMAT_PARENT_FIELD ? (bits & PARENT_FIELD_FIELD) != 0 : false;
+
+ assert (bits & 0xE0) == 0
+ : "unused bits are set \"" + Integer.toBinaryString(bits) + "\"";
+ assert format >= FORMAT_PARENT_FIELD || (bits & 0xF0) == 0
+ : "parent field bit is set but shouldn't' \"" + Integer.toBinaryString(bits) + "\"";
Review Comment:
Can we upgrade these to `CorruptIndexException` since conceivably this can happen due to user events (bad disk, RAM, whatever CPU bit fiddling, cosmic ray...)? `assert` should be reserved for cases that we feel strongly can only occur if we (Lucene sources) have a bug.
##########
lucene/core/src/java/org/apache/lucene/index/FieldInfos.java:
##########
@@ -188,6 +200,26 @@ public static FieldInfos getMergedFieldInfos(IndexReader reader) {
}
}
+ private static String getAndValidateParentField(List<LeafReaderContext> leaves) {
+ boolean set = false;
+ String theField = null;
+ for (LeafReaderContext ctx : leaves) {
+ String field = ctx.reader().getFieldInfos().getParentField();
+ if (set && Objects.equals(field, theField) == false) {
+ throw new IllegalStateException(
Review Comment:
As far as we know, users should never be able to do anything that would trigger this? This means we have some bug that allowed broken schema into the index?
##########
lucene/core/src/java/org/apache/lucene/index/FieldInfo.java:
##########
@@ -84,7 +86,8 @@ public FieldInfo(
int vectorDimension,
VectorEncoding vectorEncoding,
VectorSimilarityFunction vectorSimilarityFunction,
- boolean softDeletesField) {
+ boolean softDeletesField,
+ boolean parentField) {
Review Comment:
Could we rename the arg & member to `isParentField`?
##########
lucene/core/src/java/org/apache/lucene/index/IndexWriterConfig.java:
##########
@@ -545,4 +545,20 @@ public IndexWriterConfig setIndexWriterEventListener(
this.eventListener = eventListener;
return this;
}
+
+ /**
+ * Sets the parent document field. If this optional property is set, IndexWriter will add an
+ * internal field to every root document added to the index writer. A document is considered a
+ * parent document if it's the last document in a document block indexed via {@link
+ * IndexWriter#addDocuments(Iterable)} or {@link IndexWriter#updateDocuments(Term, Iterable)}
+ * (Iterable)} and it's relatives. Additionally, all individual documents added via the single
Review Comment:
Hmm is this `(Iterable)}` a leftover?
##########
lucene/core/src/java/org/apache/lucene/index/IndexWriterConfig.java:
##########
@@ -545,4 +545,20 @@ public IndexWriterConfig setIndexWriterEventListener(
this.eventListener = eventListener;
return this;
}
+
+ /**
+ * Sets the parent document field. If this optional property is set, IndexWriter will add an
+ * internal field to every root document added to the index writer. A document is considered a
+ * parent document if it's the last document in a document block indexed via {@link
+ * IndexWriter#addDocuments(Iterable)} or {@link IndexWriter#updateDocuments(Term, Iterable)}
+ * (Iterable)} and it's relatives. Additionally, all individual documents added via the single
Review Comment:
Also `it's` -> `its` in this sentence.
##########
lucene/core/src/java/org/apache/lucene/codecs/lucene94/Lucene94FieldInfosFormat.java:
##########
@@ -157,6 +158,13 @@ public FieldInfos read(
boolean omitNorms = (bits & OMIT_NORMS) != 0;
boolean storePayloads = (bits & STORE_PAYLOADS) != 0;
boolean isSoftDeletesField = (bits & SOFT_DELETES_FIELD) != 0;
+ boolean isParentField =
+ format >= FORMAT_PARENT_FIELD ? (bits & PARENT_FIELD_FIELD) != 0 : false;
+
+ assert (bits & 0xE0) == 0
+ : "unused bits are set \"" + Integer.toBinaryString(bits) + "\"";
+ assert format >= FORMAT_PARENT_FIELD || (bits & 0xF0) == 0
+ : "parent field bit is set but shouldn't' \"" + Integer.toBinaryString(bits) + "\"";
Review Comment:
Also fix `shouldn't'` -> `shouldn't` (remove the extra trailing single quote)?
##########
lucene/core/src/java/org/apache/lucene/index/FieldInfos.java:
##########
@@ -437,6 +486,31 @@ private void verifySoftDeletedFieldName(String fieldName, boolean isSoftDeletesF
}
}
+ private void verifyParentFieldName(String fieldName, boolean isParentField) {
+ if (isParentField) {
+ if (parentFieldName == null) {
+ throw new IllegalArgumentException(
+ "this index has ["
+ + fieldName
+ + "] as parent document field already but parent document field is not configured in IWC");
+ } else if (fieldName.equals(parentFieldName) == false) {
+ throw new IllegalArgumentException(
+ "cannot configure ["
+ + parentFieldName
+ + "] as parent document field ; this index uses ["
+ + fieldName
+ + "] as parent document field already");
+ }
+ } else if (fieldName.equals(parentFieldName)) {
+ throw new IllegalArgumentException(
Review Comment:
Maybe add a comment that this is the `else case -- isParentField == false`? On quick read I missed that extra closing `}`...
##########
lucene/core/src/java/org/apache/lucene/codecs/lucene94/Lucene94FieldInfosFormat.java:
##########
@@ -157,6 +158,8 @@ public FieldInfos read(
boolean omitNorms = (bits & OMIT_NORMS) != 0;
boolean storePayloads = (bits & STORE_PAYLOADS) != 0;
boolean isSoftDeletesField = (bits & SOFT_DELETES_FIELD) != 0;
+ boolean isParentField =
+ format >= FORMAT_PARENT_FIELD ? (bits & PARENT_FIELD_FIELD) != 0 : false;
Review Comment:
+1 for both paranoia checks? (bit is not set if format is old; no "unused" bits are ever set). Bit flags are otherwise a bit dangerous...
--
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: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Add support for index sorting with document blocks [lucene]
Posted by "s1monw (via GitHub)" <gi...@apache.org>.
s1monw commented on PR #12829:
URL: https://github.com/apache/lucene/pull/12829#issuecomment-1870447436
@mikemccand @jpountz I think it's ready. I added some more testing to it and removed storing the no. of children in the DV field to make it as low impact as possible. we can still optimize this if we want / need later internally
--
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: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Add support for index sorting with document blocks [lucene]
Posted by "s1monw (via GitHub)" <gi...@apache.org>.
s1monw commented on code in PR #12829:
URL: https://github.com/apache/lucene/pull/12829#discussion_r1440343745
##########
lucene/core/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java:
##########
@@ -231,7 +244,23 @@ long updateDocuments(
final int docsInRamBefore = numDocsInRAM;
boolean allDocsIndexed = false;
try {
- for (Iterable<? extends IndexableField> doc : docs) {
+ final Iterator<? extends Iterable<? extends IndexableField>> iterator = docs.iterator();
+ while (iterator.hasNext()) {
+ Iterable<? extends IndexableField> doc = iterator.next();
+ if (parentField != null) {
+ if (iterator.hasNext() == false) {
+ doc = addParentField(doc, parentField);
+ }
+ } else if (segmentInfo.getIndexSort() != null
+ && iterator.hasNext()
+ && indexVersionCreated >= Version.LUCENE_10_0_0.major) {
+ // sort is configured but parent field is missing, yet we have a doc-block
+ // yet we must not fail if this index was created in an earlier version where this
+ // behavior was permitted.
+ throw new IllegalArgumentException(
+ "a parent field must be set in order to use document blocks with index sorting; see IndexWriterConfig#getParentField");
Review Comment:
nah you are right
--
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: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Add support for index sorting with document blocks [lucene]
Posted by "s1monw (via GitHub)" <gi...@apache.org>.
s1monw commented on PR #12829:
URL: https://github.com/apache/lucene/pull/12829#issuecomment-1824135498
> I'm a little worried about giving up functionality, but I think if we had a list of parent-fields rather than a single parent-field that would cover what we can do today? Maybe one is enough - you can still do hierarchies with one field, but today's API actually let's you define multiple overlapping relations.
I don't think we give up any functionality. can you elaborate what functionality you are referring to? I don't think we should have a list of parent fields that IW requires, what would that list be used for? I also don't understand how the APU lets you define overlapping relations that this change would prevent you from?
--
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: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Add support for index sorting with document blocks [lucene]
Posted by "mikemccand (via GitHub)" <gi...@apache.org>.
mikemccand commented on PR #12829:
URL: https://github.com/apache/lucene/pull/12829#issuecomment-1840782006
Thanks @s1monw -- I'll try to review soon.
> The only think I am torn on is, if we set the num of children as a value for the DV field then I guess we should have a good usecase for that?
One thing this would be helpful for is stronger consistency check in `CheckIndex`? Without doing this we can just validate that the parent docs are sorted correctly, whereas today we verify that all docs are sorted correctly (since user must provide a sort congruent with their doc-blocks). So we are weakening `CheckIndex` a bit by skipping checking the sort of the child docs ... if we stored the number of children in the new DV field, we could gain that back?
--
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: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Add support for index sorting with document blocks [lucene]
Posted by "s1monw (via GitHub)" <gi...@apache.org>.
s1monw commented on code in PR #12829:
URL: https://github.com/apache/lucene/pull/12829#discussion_r1434193511
##########
lucene/core/src/java/org/apache/lucene/index/CheckIndex.java:
##########
@@ -1180,33 +1180,43 @@ public static Status.IndexSortStatus testSort(
comparators[i] = fields[i].getComparator(1, Pruning.NONE).getLeafComparator(readerContext);
}
- int maxDoc = reader.maxDoc();
-
try {
-
- for (int docID = 1; docID < maxDoc; docID++) {
-
+ LeafMetaData metaData = reader.getMetaData();
+ FieldInfos fieldInfos = reader.getFieldInfos();
+ if (metaData.hasBlocks()
+ && fieldInfos.getParentField() == null
+ && metaData.getCreatedVersionMajor() >= Version.LUCENE_10_0_0.major) {
+ throw new IllegalStateException(
+ "parent field is not set but the index has document blocks and was created with version: "
+ + metaData.getCreatedVersionMajor());
+ }
+ final DocIdSetIterator iter =
+ metaData.hasBlocks() && fieldInfos.getParentField() != null
+ ? reader.getNumericDocValues(fieldInfos.getParentField())
+ : DocIdSetIterator.all(reader.maxDoc());
+ int prevDoc = iter.nextDoc();
+ int nextDoc;
+ while ((nextDoc = iter.nextDoc()) != NO_MORE_DOCS) {
int cmp = 0;
-
for (int i = 0; i < comparators.length; i++) {
- // TODO: would be better if copy() didnt cause a term lookup in TermOrdVal & co,
+ // TODO: would be better if copy() didn't cause a term lookup in TermOrdVal & co,
// the segments are always the same here...
- comparators[i].copy(0, docID - 1);
+ comparators[i].copy(0, prevDoc);
comparators[i].setBottom(0);
- cmp = reverseMul[i] * comparators[i].compareBottom(docID);
+ cmp = reverseMul[i] * comparators[i].compareBottom(nextDoc);
if (cmp != 0) {
break;
}
}
-
+ prevDoc = nextDoc;
Review Comment:
good catch
--
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: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Add support for index sorting with document blocks [lucene]
Posted by "mikemccand (via GitHub)" <gi...@apache.org>.
mikemccand commented on code in PR #12829:
URL: https://github.com/apache/lucene/pull/12829#discussion_r1439716624
##########
lucene/core/src/java/org/apache/lucene/index/CheckIndex.java:
##########
@@ -1176,34 +1176,44 @@ public static Status.IndexSortStatus testSort(
comparators[i] = fields[i].getComparator(1, Pruning.NONE).getLeafComparator(readerContext);
}
- int maxDoc = reader.maxDoc();
-
try {
-
- for (int docID = 1; docID < maxDoc; docID++) {
-
+ LeafMetaData metaData = reader.getMetaData();
+ FieldInfos fieldInfos = reader.getFieldInfos();
+ if (metaData.hasBlocks()
+ && fieldInfos.getParentField() == null
+ && metaData.getCreatedVersionMajor() >= Version.LUCENE_10_0_0.major) {
+ throw new IllegalStateException(
+ "parent field is not set but the index has document blocks and was created with version: "
+ + metaData.getCreatedVersionMajor());
+ }
+ final DocIdSetIterator iter =
Review Comment:
Hmm maybe un-ternary this one?
##########
lucene/CHANGES.txt:
##########
@@ -90,6 +90,11 @@ New Features
* LUCENE-10626 Hunspell: add tools to aid dictionary editing:
analysis introspection, stem expansion and stem/flag suggestion (Peter Gromov)
+* GITHUB#12829: IndexWriter now preserves document blocks indexed via IndexWriter#addDocuments
+ et.al. when index sorting is configured. Document blocks are maintained alongside their
+ parent documents during sort and merge. IndexWriterConfig requires a parent field to be specified
+ if index sorting is used together with documents blocks. (Simon Willnauer)
Review Comment:
`documents blocks` -> `document blocks`
##########
lucene/core/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java:
##########
@@ -134,6 +137,8 @@ void abort() throws IOException {
private final ReentrantLock lock = new ReentrantLock();
private int[] deleteDocIDs = new int[0];
private int numDeletedDocIds = 0;
+ private final int indexVersionCreated;
Review Comment:
Rename to `indexMajorVersionCreated`?
##########
lucene/core/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java:
##########
@@ -231,7 +244,23 @@ long updateDocuments(
final int docsInRamBefore = numDocsInRAM;
boolean allDocsIndexed = false;
try {
- for (Iterable<? extends IndexableField> doc : docs) {
+ final Iterator<? extends Iterable<? extends IndexableField>> iterator = docs.iterator();
+ while (iterator.hasNext()) {
+ Iterable<? extends IndexableField> doc = iterator.next();
+ if (parentField != null) {
+ if (iterator.hasNext() == false) {
+ doc = addParentField(doc, parentField);
+ }
+ } else if (segmentInfo.getIndexSort() != null
+ && iterator.hasNext()
+ && indexVersionCreated >= Version.LUCENE_10_0_0.major) {
+ // sort is configured but parent field is missing, yet we have a doc-block
+ // yet we must not fail if this index was created in an earlier version where this
+ // behavior was permitted.
+ throw new IllegalArgumentException(
+ "a parent field must be set in order to use document blocks with index sorting; see IndexWriterConfig#getParentField");
Review Comment:
Maybe `#setParentField` instead? Or is the javadoc mostly on `getParentField` if so leave this be.
##########
lucene/core/src/java/org/apache/lucene/index/IndexingChain.java:
##########
@@ -1512,4 +1557,77 @@ void assertSameSchema(FieldInfo fi) {
assertSame("point num bytes", fi.getPointNumBytes(), pointNumBytes);
}
}
+
+ /**
+ * Wraps the given field in a reserved field and registers it as reserved. Only DWPT should do
+ * this to mark fields as private / reserved to prevent this fieldname to be used from the outside
Review Comment:
+1 to tighten up the language.
##########
lucene/core/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java:
##########
@@ -245,10 +274,11 @@ long updateDocuments(
onNewDocOnRAM.run();
}
}
- allDocsIndexed = true;
- if (numDocsInRAM - docsInRamBefore > 1) {
+ final int numDocs = numDocsInRAM - docsInRamBefore;
+ if (numDocs > 1) {
segmentInfo.setHasBlocks();
Review Comment:
This might mean some segments don't have `hasBlocks` set but some do, if all doc blocks in a given segment happened to have just one doc. That should be OK? Nothing checks that all segments have the same boolean value for this? Maybe add a test case to confirm?
##########
lucene/core/src/java/org/apache/lucene/index/FieldInfos.java:
##########
@@ -437,6 +488,31 @@ private void verifySoftDeletedFieldName(String fieldName, boolean isSoftDeletesF
}
}
+ private void verifyParentFieldName(String fieldName, boolean isParentField) {
+ if (isParentField) {
+ if (parentFieldName == null) {
+ throw new IllegalArgumentException(
+ "this index has ["
+ + fieldName
+ + "] as parent document field already but parent document field is not configured in IWC");
+ } else if (fieldName.equals(parentFieldName) == false) {
+ throw new IllegalArgumentException(
+ "cannot configure ["
+ + parentFieldName
+ + "] as parent document field ; this index uses ["
+ + fieldName
+ + "] as parent document field already");
Review Comment:
Extra space between `field` and `already`?
##########
lucene/CHANGES.txt:
##########
@@ -90,6 +90,11 @@ New Features
* LUCENE-10626 Hunspell: add tools to aid dictionary editing:
analysis introspection, stem expansion and stem/flag suggestion (Peter Gromov)
+* GITHUB#12829: IndexWriter now preserves document blocks indexed via IndexWriter#addDocuments
+ et.al. when index sorting is configured. Document blocks are maintained alongside their
Review Comment:
Maybe say `or #updateDocuments`? Those are the only two methods?
##########
lucene/core/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java:
##########
@@ -262,6 +292,35 @@ long updateDocuments(
}
}
+ private Iterable<? extends IndexableField> addParentField(
+ Iterable<? extends IndexableField> doc, IndexableField parentField) {
+ return () -> {
+ final Iterator<? extends IndexableField> first = doc.iterator();
+ return new Iterator<>() {
+ IndexableField additionalField = parentField;
+
+ @Override
+ public boolean hasNext() {
+ return additionalField != null || first.hasNext();
+ }
+
+ @Override
+ public IndexableField next() {
+ if (additionalField != null) {
+ IndexableField field = additionalField;
+ additionalField = null;
+ return field;
+ }
+ if (first.hasNext()) {
+ IndexableField field = first.next();
+ return field;
Review Comment:
Maybe just `return first.next();`?
##########
lucene/CHANGES.txt:
##########
@@ -131,6 +136,13 @@ Bug Fixes
* GITHUB#12878: Fix the declared Exceptions of Expression#evaluate() to match those
of DoubleValues#doubleValue(). (Uwe Schindler)
+Changes in Backwards Compatibility Policy
+-----------------------------------------
+
+* GITHUB#12829: IndexWriter#addDocuments et.al. now require a parent field name to be
Review Comment:
Maybe insert `For indices newly created as of 10.0.0 onwards, ...`?
Also, maybe move this to `MIGRATE.txt`, or keep this one here but also add one to `MIGRATE.txt`?
And `et.al.` -> `or #updateDocuments`?
##########
lucene/core/src/java/org/apache/lucene/index/FieldInfos.java:
##########
@@ -437,6 +486,31 @@ private void verifySoftDeletedFieldName(String fieldName, boolean isSoftDeletesF
}
}
+ private void verifyParentFieldName(String fieldName, boolean isParentField) {
+ if (isParentField) {
+ if (parentFieldName == null) {
+ throw new IllegalArgumentException(
+ "this index has ["
+ + fieldName
+ + "] as parent document field already but parent document field is not configured in IWC");
+ } else if (fieldName.equals(parentFieldName) == false) {
+ throw new IllegalArgumentException(
+ "cannot configure ["
+ + parentFieldName
+ + "] as parent document field ; this index uses ["
+ + fieldName
+ + "] as parent document field already");
+ }
+ } else if (fieldName.equals(parentFieldName)) {
+ throw new IllegalArgumentException(
+ "cannot configure ["
+ + parentFieldName
+ + "] as parent document field ; this index uses ["
Review Comment:
OK I think I'm confused about how this code is working/catching something.
`parentFieldName` is what was configured in IWC, and the incoming `fieldName` is coming from ... a document being newly indexed where this in-memory segment is seeing this `fieldName` for the first time and creating a `FieldInfo` for it? Hmm but then how is that new `FieldInfo` setting its `.isParentField`? Sorry I gotta stare at this / think about this a bit more :)
--
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: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Add support for index sorting with document blocks [lucene]
Posted by "s1monw (via GitHub)" <gi...@apache.org>.
s1monw commented on code in PR #12829:
URL: https://github.com/apache/lucene/pull/12829#discussion_r1413065291
##########
lucene/core/src/java/org/apache/lucene/search/Sort.java:
##########
@@ -59,10 +61,28 @@ public Sort() {
* is still a tie after all SortFields are checked, the internal Lucene docid is used to break it.
*/
public Sort(SortField... fields) {
+ this(null, fields);
+ }
+
+ /**
+ * Sets the sort to the given criteria in succession: the first SortField is checked first, but if
+ * it produces a tie, then the second SortField is used to break the tie, etc. Finally, if there
+ * is still a tie after all SortFields are checked, the internal Lucene docid is used to break it.
+ *
+ * @param parentField the name of a numeric doc values field that marks the last document of a
Review Comment:
well I guess we could do something with that field at search time. Yet, at this point it's indexing time only
--
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: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Add support for index sorting with document blocks [lucene]
Posted by "s1monw (via GitHub)" <gi...@apache.org>.
s1monw commented on code in PR #12829:
URL: https://github.com/apache/lucene/pull/12829#discussion_r1442110320
##########
lucene/core/src/java/org/apache/lucene/index/FieldInfos.java:
##########
@@ -437,6 +488,33 @@ private void verifySoftDeletedFieldName(String fieldName, boolean isSoftDeletesF
}
}
+ private void verifyParentFieldName(String fieldName, boolean isParentField) {
+ if (isParentField) {
+ if (parentFieldName == null) {
+ throw new IllegalArgumentException(
+ "this index has ["
+ + fieldName
+ + "] as parent document field already but parent document field is not configured in IWC");
+ } else if (fieldName.equals(parentFieldName) == false) {
+ throw new IllegalArgumentException(
+ "cannot configure ["
+ + parentFieldName
+ + "] as parent document field ; this index uses ["
+ + fieldName
Review Comment:
I think this is confusing from it's name. The `parentFieldName` comes from IWC and fieldname is the incoming field. I think it's right the way it is, maybe we need to do some rewording altogether but when you look at the tests I think the error message makes sense?
I would like to find a way that users don't have to specify these fieldnames altogether but that should be a follow up
--
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: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Add support for index sorting with document blocks [lucene]
Posted by "s1monw (via GitHub)" <gi...@apache.org>.
s1monw commented on PR #12829:
URL: https://github.com/apache/lucene/pull/12829#issuecomment-1866428159
> If my understanding is correct, we will require a parent field when using blocks as of 10.0. One concern I have about this is that we currently don't require users to know up-front whether they'll be indexing join blocks. This suggests that users should always set the parent field in practice if they want to have a chance to index blocks later on?
This is almost correct. you can use blocks without the parent field unless you use sort. if you use index sorting it's required and has to be set up-front. We can make this smarter down the road but I am not sure we need to. it's really a single bit per document that it needs unless we stick to the number of children as a value which I am opposed to.
--
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: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Add support for index sorting with document blocks [lucene]
Posted by "s1monw (via GitHub)" <gi...@apache.org>.
s1monw commented on code in PR #12829:
URL: https://github.com/apache/lucene/pull/12829#discussion_r1434189939
##########
lucene/core/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java:
##########
@@ -262,6 +294,35 @@ long updateDocuments(
}
}
+ private Iterable<? extends IndexableField> addParentField(
+ Iterable<? extends IndexableField> doc, IndexableField parentField) {
+ return () -> {
+ final Iterator<? extends IndexableField> first = doc.iterator();
+ return new Iterator<>() {
+ IndexableField additionalField = parentField;
+
+ @Override
+ public boolean hasNext() {
+ return first.hasNext() || additionalField != null;
+ }
+
+ @Override
+ public IndexableField next() {
+ if (first.hasNext()) {
+ IndexableField field = first.next();
+ return field;
+ }
+ if (additionalField != null) {
+ IndexableField field = additionalField;
+ additionalField = null;
+ return field;
Review Comment:
sure lemme do that
--
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: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Add support for index sorting with document blocks [lucene]
Posted by "msokolov (via GitHub)" <gi...@apache.org>.
msokolov commented on PR #12829:
URL: https://github.com/apache/lucene/pull/12829#issuecomment-1828402628
> I don't think we give up any functionality. can you elaborate what functionality you are referring to? I don't think we should have a list of parent fields that IW requires, what would that list be used for? I also don't understand how the APU lets you define overlapping relations that this change would prevent you from?
I think we have always been able to model a multi-level hierarchy. Suppose I index a book broken into documents representing paragraphs grouped into sections, chapters, and parts; so it's a five-level hierarchy. There can be documents at every level and we want to be able to do roll-ups to any level. If I index a book as a block, we support this today.
I might be confused, but I didn't think that would work with this arrangement. However maybe it does? I guess one describes every component document as having the book as a parent, and then later can still use a different parent bitset to do the roll-ups to other levels?
--
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: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Add support for index sorting with document blocks [lucene]
Posted by "mikemccand (via GitHub)" <gi...@apache.org>.
mikemccand commented on PR #12829:
URL: https://github.com/apache/lucene/pull/12829#issuecomment-1827825175
> using a doc-value field where only parents documents have a value for the field, and the value must be the number of child documents that the parent has
This is a neat idea too -- would this maybe make completing the join at search time more efficient? Today we scan for the next set bit, but I guess with this approach, we'd still scan for the next `NumericDocValues` that is set, and then see the child count, but that would be sort of redundant (we could still subtract docids to get the number of children)? Also, I'm not sure how the nested case would be supported (same as the current PR's approach too).
> This makes me wonder if Lucene could be adding this doc value field for root documents automatically, similarly to what it is doing for soft deletes? (Possibly in a follow-up PR)
This is a nice idea too, but I think we'd still need user input to give us a free field name to use for this purpose.
--
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: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Add support for index sorting with document blocks [lucene]
Posted by "msokolov (via GitHub)" <gi...@apache.org>.
msokolov commented on PR #12829:
URL: https://github.com/apache/lucene/pull/12829#issuecomment-1823517625
I like @jpountz's idea to make the value of this field be the number of children. It is simple and makes sense, and is pretty close to having the degree of flexibility that the current setup has.
I'm a little worried about giving up functionality, but I think if we had a list of parent-fields rather than a single parent-field that would cover what we can do today? Maybe one is enough - you can still do hierarchies with one field, but today's API actually let's you define multiple overlapping relations.
--
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: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Add support for index sorting with document blocks [lucene]
Posted by "s1monw (via GitHub)" <gi...@apache.org>.
s1monw commented on code in PR #12829:
URL: https://github.com/apache/lucene/pull/12829#discussion_r1419209272
##########
lucene/backward-codecs/src/test/org/apache/lucene/backward_index/TestBackwardsCompatibility.java:
##########
@@ -2164,6 +2166,83 @@ public void testSortedIndex() throws Exception {
}
}
+ public void testSortedIndexAddDocBlocks() throws Exception {
+ for (String name : oldSortedNames) {
+ Path path = createTempDir("sorted");
+ InputStream resource = TestBackwardsCompatibility.class.getResourceAsStream(name + ".zip");
+ assertNotNull("Sorted index index " + name + " not found", resource);
+ TestUtil.unzip(resource, path);
+
+ try (Directory dir = newFSDirectory(path)) {
+ final Sort sort;
+ try (DirectoryReader reader = DirectoryReader.open(dir)) {
+ assertEquals(1, reader.leaves().size());
+ sort = reader.leaves().get(0).reader().getMetaData().getSort();
+ assertNotNull(sort);
+ searchExampleIndex(reader);
+ }
+ // open writer
+ try (IndexWriter writer =
+ new IndexWriter(
+ dir,
+ newIndexWriterConfig(new MockAnalyzer(random()))
+ .setOpenMode(OpenMode.APPEND)
+ .setIndexSort(sort)
+ .setMergePolicy(newLogMergePolicy()))) {
+ // add 10 docs
+ for (int i = 0; i < 10; i++) {
Review Comment:
yes, unless we 1. backport this which is possible and 2. if you set a parent field in the old index. yet I can't fully test that just yet since it's not backported. makes sense?
--
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: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Add support for index sorting with document blocks [lucene]
Posted by "s1monw (via GitHub)" <gi...@apache.org>.
s1monw commented on code in PR #12829:
URL: https://github.com/apache/lucene/pull/12829#discussion_r1434180897
##########
lucene/core/src/java/org/apache/lucene/codecs/lucene94/Lucene94FieldInfosFormat.java:
##########
@@ -157,6 +158,8 @@ public FieldInfos read(
boolean omitNorms = (bits & OMIT_NORMS) != 0;
boolean storePayloads = (bits & STORE_PAYLOADS) != 0;
boolean isSoftDeletesField = (bits & SOFT_DELETES_FIELD) != 0;
+ boolean isParentField =
+ format >= FORMAT_PARENT_FIELD ? (bits & PARENT_FIELD_FIELD) != 0 : false;
Review Comment:
I can add a check that fails if any bit is set after the one we use. Not sure it's necessary.
--
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: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Add support for index sorting with document blocks [lucene]
Posted by "s1monw (via GitHub)" <gi...@apache.org>.
s1monw commented on PR #12829:
URL: https://github.com/apache/lucene/pull/12829#issuecomment-1852410786
@mikemccand I agree we should not add this to sort but rather tread it the same way we treat the softDeletes field. it's essentially the same thing from an IW perspective. I will go ahead an make that change.
--
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: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Add support for index sorting with document blocks [lucene]
Posted by "mikemccand (via GitHub)" <gi...@apache.org>.
mikemccand commented on PR #12829:
URL: https://github.com/apache/lucene/pull/12829#issuecomment-1855755782
One small observation here: one can use the `add/updateDocuments` API today with no intention of using those as doc blocks at search time, purely as an optimization over calling separate `addDocument` every time.
I'm not sure what performance difference this makes, but it should only help speed up indexing throughput.
E.g. [luceneserver](https://github.com/mikemccand/luceneserver) (the search engine behind [jirasearch](https://jirasearch.mikemccandless.com/search.py) and soon now [githubsearch](https://githubsearch.mikemccandless.com/search.py)) does this in its bulk indexing API, I think.
This saves the IW/DWPT overhead, but comes with some risk if your blocks are too big since IW cannot flush until the block is done.
With this change, I think such usage would still be fine if you have no index sort? But if you have an index sort, then IW will always do the parent block validation / tracking?
I think net/net this is fine, I just wanted to call it out, for crazy people trying to eek out every last bit of indexing throughput :)
--
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: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Add support for index sorting with document blocks [lucene]
Posted by "mikemccand (via GitHub)" <gi...@apache.org>.
mikemccand commented on code in PR #12829:
URL: https://github.com/apache/lucene/pull/12829#discussion_r1440668657
##########
lucene/core/src/java/org/apache/lucene/index/FieldInfos.java:
##########
@@ -132,6 +135,13 @@ public FieldInfos(FieldInfo[] infos) {
}
softDeletesField = info.name;
}
+ if (info.isParentField()) {
+ if (parentField != null && parentField.equals(info.name) == false) {
+ throw new IllegalArgumentException(
+ "multiple parent fields [" + info.name + ", " + parentField + "]");
Review Comment:
@s1monw did you miss this one ^^?
--
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: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Add support for index sorting with document blocks [lucene]
Posted by "s1monw (via GitHub)" <gi...@apache.org>.
s1monw commented on PR #12829:
URL: https://github.com/apache/lucene/pull/12829#issuecomment-1862667309
@mikemccand I don't think we have any impact on performance here at all if this feature is not in use. If you look at DWPT there is a final field that decides if there is further examination. But if the parent field is not set this entire path if skipped and should be optimized away by jit. Lets see what benchmarks say.
--
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: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Add support for index sorting with document blocks [lucene]
Posted by "jpountz (via GitHub)" <gi...@apache.org>.
jpountz commented on PR #12829:
URL: https://github.com/apache/lucene/pull/12829#issuecomment-1823167735
In general, I like the idea of making block joins more of a first-class citizen. I have been thinking for a long time about changing how blocks are identified from using bitsets to using a doc-value field where only parents documents have a value for the field, and the value must be the number of child documents that the parent has. This PR would like to identify blocks with a doc-values field as well, which is interesting. This makes me wonder if Lucene could be adding this doc value field for root documents automatically, similarly to what it is doing for soft deletes? (Possibly in a follow-up PR)
--
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: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Add support for index sorting with document blocks [lucene]
Posted by "mikemccand (via GitHub)" <gi...@apache.org>.
mikemccand commented on code in PR #12829:
URL: https://github.com/apache/lucene/pull/12829#discussion_r1426637555
##########
lucene/backward-codecs/src/test/org/apache/lucene/backward_index/TestBackwardsCompatibility.java:
##########
@@ -2164,6 +2166,83 @@ public void testSortedIndex() throws Exception {
}
}
+ public void testSortedIndexAddDocBlocks() throws Exception {
+ for (String name : oldSortedNames) {
+ Path path = createTempDir("sorted");
+ InputStream resource = TestBackwardsCompatibility.class.getResourceAsStream(name + ".zip");
+ assertNotNull("Sorted index index " + name + " not found", resource);
+ TestUtil.unzip(resource, path);
+
+ try (Directory dir = newFSDirectory(path)) {
+ final Sort sort;
+ try (DirectoryReader reader = DirectoryReader.open(dir)) {
+ assertEquals(1, reader.leaves().size());
+ sort = reader.leaves().get(0).reader().getMetaData().getSort();
+ assertNotNull(sort);
+ searchExampleIndex(reader);
+ }
+ // open writer
+ try (IndexWriter writer =
+ new IndexWriter(
+ dir,
+ newIndexWriterConfig(new MockAnalyzer(random()))
+ .setOpenMode(OpenMode.APPEND)
+ .setIndexSort(sort)
+ .setMergePolicy(newLogMergePolicy()))) {
+ // add 10 docs
+ for (int i = 0; i < 10; i++) {
Review Comment:
Yeah this makes sense -- if you have a pre-10.0 index, then none of the new code is run. You must create a new index to get the stronger checking.
(Or, 9.10.x index if we backport).
--
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: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Add support for index sorting with document blocks [lucene]
Posted by "msokolov (via GitHub)" <gi...@apache.org>.
msokolov commented on code in PR #12829:
URL: https://github.com/apache/lucene/pull/12829#discussion_r1421566628
##########
lucene/core/src/java/org/apache/lucene/index/IndexingChain.java:
##########
@@ -219,15 +222,33 @@ private Sorter.DocMap maybeSortSegment(SegmentWriteState state) throws IOExcepti
}
LeafReader docValuesReader = getDocValuesLeafReader();
-
+ Function<IndexSorter.DocComparator, IndexSorter.DocComparator> comparatorWrapper = in -> in;
+
+ if (state.segmentInfo.getHasBlocks() && indexSort.getParentField() != null) {
+ final DocIdSetIterator readerValues =
+ docValuesReader.getNumericDocValues(indexSort.getParentField());
+ BitSet parents = BitSet.of(readerValues, state.segmentInfo.maxDoc());
+ comparatorWrapper =
+ in ->
+ (docID1, docID2) ->
+ in.compare(parents.nextSetBit(docID1), parents.nextSetBit(docID2));
+ }
+ assert state.segmentInfo.getHasBlocks() == false
+ || indexSort.getParentField() != null
+ || indexCreatedVersionMajor < Version.LUCENE_10_0_0.major
+ : "parent field is not set but the index has blocks. indexCreatedVersionMajor: "
+ + indexCreatedVersionMajor;
List<IndexSorter.DocComparator> comparators = new ArrayList<>();
for (int i = 0; i < indexSort.getSort().length; i++) {
SortField sortField = indexSort.getSort()[i];
IndexSorter sorter = sortField.getIndexSorter();
if (sorter == null) {
throw new UnsupportedOperationException("Cannot sort index using sort field " + sortField);
}
- comparators.add(sorter.getDocComparator(docValuesReader, state.segmentInfo.maxDoc()));
+
+ IndexSorter.DocComparator docComparator =
Review Comment:
This is a little late here, and I don't want to derail things, but I thought I would mention another plan that someone on our team worked up and never shared, which is a custom comparator that accepts a parent bitset-supplier and uses that to supply sort values for the child documents from the parent documents. This opens the possibility of defining the parents externally, possibly using a Query, rather than relying on an explicit indexed field.
--
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: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Add support for index sorting with document blocks [lucene]
Posted by "s1monw (via GitHub)" <gi...@apache.org>.
s1monw commented on code in PR #12829:
URL: https://github.com/apache/lucene/pull/12829#discussion_r1415196168
##########
lucene/core/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java:
##########
@@ -262,6 +277,73 @@ long updateDocuments(
}
}
+ private interface DocValidator extends Consumer<IndexableField> {
Review Comment:
I removed it and went down a different route
--
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: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Add support for index sorting with document blocks [lucene]
Posted by "mikemccand (via GitHub)" <gi...@apache.org>.
mikemccand commented on code in PR #12829:
URL: https://github.com/apache/lucene/pull/12829#discussion_r1415586966
##########
lucene/core/src/test/org/apache/lucene/index/TestAddIndexes.java:
##########
@@ -1678,6 +1678,51 @@ public void testIllegalIndexSortChange2() throws Exception {
IOUtils.close(r1, dir1, w2, dir2);
}
+ public void testIllegalIndexSortChange3() throws Exception {
+ Directory dir1 = newDirectory();
+ IndexWriterConfig iwc1 = newIndexWriterConfig(new MockAnalyzer(random()));
+ iwc1.setIndexSort(new Sort("foobar", new SortField("foo", SortField.Type.INT)));
+
+ RandomIndexWriter w1 = new RandomIndexWriter(random(), dir1, iwc1);
+ Document parent = new Document();
+ w1.addDocuments(Arrays.asList(new Document(), new Document(), parent));
+ w1.commit();
+ w1.addDocuments(Arrays.asList(new Document(), new Document(), parent));
+ w1.commit();
+ // so the index sort is in fact burned into the index:
+ w1.forceMerge(1);
+ w1.close();
+
+ Directory dir2 = newDirectory();
+ IndexWriterConfig iwc2 = newIndexWriterConfig(new MockAnalyzer(random()));
+ iwc2.setIndexSort(new Sort(new SortField("foo", SortField.Type.INT)));
+ RandomIndexWriter w2 = new RandomIndexWriter(random(), dir2, iwc2);
+
+ IndexReader r1 = DirectoryReader.open(dir1);
+ String message =
+ expectThrows(
+ IllegalArgumentException.class,
+ () -> {
+ w2.addIndexes((SegmentReader) getOnlyLeafReader(r1));
+ })
+ .getMessage();
+ assertEquals(
+ "cannot change index sort from parent field: foobar <int: \"foo\"> to <int: \"foo\">",
+ message);
+
+ message =
+ expectThrows(
+ IllegalArgumentException.class,
+ () -> {
+ w2.addIndexes(dir1);
Review Comment:
Can we also test that if you `.addIndexes` with the correct configuration (same parent sort field) things are good?
##########
lucene/core/src/java/org/apache/lucene/index/CheckIndex.java:
##########
@@ -1198,33 +1198,42 @@ public static Status.IndexSortStatus testSort(
comparators[i] = fields[i].getComparator(1, Pruning.NONE).getLeafComparator(readerContext);
}
- int maxDoc = reader.maxDoc();
-
try {
-
- for (int docID = 1; docID < maxDoc; docID++) {
-
+ LeafMetaData metaData = reader.getMetaData();
+ if (metaData.hasBlocks()
+ && sort.getParentField() == null
+ && metaData.getCreatedVersionMajor() >= Version.LUCENE_10_0_0.major) {
+ throw new IllegalStateException(
+ "parent field is not set but the index has block and was created with version: "
Review Comment:
`has block` -> `has document blocks`?
##########
lucene/backward-codecs/src/test/org/apache/lucene/backward_index/TestBackwardsCompatibility.java:
##########
@@ -2164,6 +2166,83 @@ public void testSortedIndex() throws Exception {
}
}
+ public void testSortedIndexAddDocBlocks() throws Exception {
+ for (String name : oldSortedNames) {
+ Path path = createTempDir("sorted");
+ InputStream resource = TestBackwardsCompatibility.class.getResourceAsStream(name + ".zip");
+ assertNotNull("Sorted index index " + name + " not found", resource);
+ TestUtil.unzip(resource, path);
+
+ try (Directory dir = newFSDirectory(path)) {
+ final Sort sort;
+ try (DirectoryReader reader = DirectoryReader.open(dir)) {
+ assertEquals(1, reader.leaves().size());
+ sort = reader.leaves().get(0).reader().getMetaData().getSort();
+ assertNotNull(sort);
+ searchExampleIndex(reader);
+ }
+ // open writer
+ try (IndexWriter writer =
+ new IndexWriter(
+ dir,
+ newIndexWriterConfig(new MockAnalyzer(random()))
+ .setOpenMode(OpenMode.APPEND)
+ .setIndexSort(sort)
+ .setMergePolicy(newLogMergePolicy()))) {
+ // add 10 docs
+ for (int i = 0; i < 10; i++) {
+ Document child = new Document();
+ child.add(new StringField("relation", "child", Field.Store.NO));
+ child.add(new StringField("bid", "" + i, Field.Store.NO));
+ child.add(new NumericDocValuesField("dateDV", i));
+ Document parent = new Document();
+ parent.add(new StringField("relation", "parent", Field.Store.NO));
+ parent.add(new StringField("bid", "" + i, Field.Store.NO));
+ parent.add(new NumericDocValuesField("dateDV", i));
+ writer.addDocuments(Arrays.asList(child, child, parent));
+ if (random().nextBoolean()) {
+ writer.flush();
+ }
+ }
+ if (random().nextBoolean()) {
+ writer.forceMerge(1);
+ }
+ writer.commit();
+ try (IndexReader reader = DirectoryReader.open(dir)) {
+ IndexSearcher searcher = new IndexSearcher(reader);
+ for (int i = 0; i < 10; i++) {
+ TopDocs children =
+ searcher.search(
+ new BooleanQuery.Builder()
+ .add(
+ new TermQuery(new Term("relation", "child")),
+ BooleanClause.Occur.MUST)
+ .add(new TermQuery(new Term("bid", "" + i)), BooleanClause.Occur.MUST)
+ .build(),
+ 2);
+ TopDocs parents =
+ searcher.search(
+ new BooleanQuery.Builder()
+ .add(
+ new TermQuery(new Term("relation", "parent")),
+ BooleanClause.Occur.MUST)
+ .add(new TermQuery(new Term("bid", "" + i)), BooleanClause.Occur.MUST)
+ .build(),
+ 2);
+ assertEquals(2, children.totalHits.value);
+ assertEquals(1, parents.totalHits.value);
+ // make sure it's sorted
+ assertEquals(children.scoreDocs[0].doc + 1, children.scoreDocs[1].doc);
+ assertEquals(children.scoreDocs[1].doc + 1, parents.scoreDocs[0].doc);
+ }
+ }
+ }
+ // This will confirm the docs are really sorted
+ TestUtil.checkIndex(dir);
Review Comment:
Hmm can we fix `CheckIndex` to confirm the blocks are also intact?
Edit: yay! It looks like you did that already :) Or rather, fixed CheckIndex so that when it validates the sort it checks only that the parent docs are in the right order.
##########
lucene/backward-codecs/src/test/org/apache/lucene/backward_index/TestBackwardsCompatibility.java:
##########
@@ -2164,6 +2166,83 @@ public void testSortedIndex() throws Exception {
}
}
+ public void testSortedIndexAddDocBlocks() throws Exception {
+ for (String name : oldSortedNames) {
+ Path path = createTempDir("sorted");
+ InputStream resource = TestBackwardsCompatibility.class.getResourceAsStream(name + ".zip");
+ assertNotNull("Sorted index index " + name + " not found", resource);
+ TestUtil.unzip(resource, path);
+
+ try (Directory dir = newFSDirectory(path)) {
+ final Sort sort;
+ try (DirectoryReader reader = DirectoryReader.open(dir)) {
+ assertEquals(1, reader.leaves().size());
+ sort = reader.leaves().get(0).reader().getMetaData().getSort();
+ assertNotNull(sort);
+ searchExampleIndex(reader);
+ }
+ // open writer
+ try (IndexWriter writer =
+ new IndexWriter(
+ dir,
+ newIndexWriterConfig(new MockAnalyzer(random()))
+ .setOpenMode(OpenMode.APPEND)
+ .setIndexSort(sort)
+ .setMergePolicy(newLogMergePolicy()))) {
+ // add 10 docs
+ for (int i = 0; i < 10; i++) {
Review Comment:
This is testing indexing doc blocks into an old (pre-10.0) index right? In this case does IW still add the DV field to the parent doc? The test here seems not to be configuring a parent field, so I guess no? Only indices created 10.0+ will do this?
##########
lucene/core/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java:
##########
@@ -262,6 +290,44 @@ long updateDocuments(
}
}
+ private Iterable<? extends IndexableField> filterParentDocField(
+ Iterable<? extends IndexableField> doc,
+ String parentFieldName,
+ NumericDocValuesField parentDocMarker) {
+ return () -> {
+ final Iterator<? extends IndexableField> first = doc.iterator();
+ return new Iterator<>() {
Review Comment:
I'm concerned about the performance impact of re-iterating / checking every Iterable the caller already passed in. Should we test the performance impact of blocks indexing? `luceneutil` indexes doc blocks for grouping ... we could test the impact there? Once this PR gets closer let me know and I'm happy to test.
##########
lucene/core/src/java/org/apache/lucene/index/IndexingChain.java:
##########
@@ -219,15 +222,33 @@ private Sorter.DocMap maybeSortSegment(SegmentWriteState state) throws IOExcepti
}
LeafReader docValuesReader = getDocValuesLeafReader();
-
+ Function<IndexSorter.DocComparator, IndexSorter.DocComparator> comparatorWrapper = in -> in;
+
+ if (state.segmentInfo.getHasBlocks() && indexSort.getParentField() != null) {
+ final DocIdSetIterator readerValues =
Review Comment:
Check that this is non-null and throw `CorruptIndexException` or so if it is null?
##########
lucene/core/src/java/org/apache/lucene/search/Sort.java:
##########
@@ -59,10 +61,28 @@ public Sort() {
* is still a tie after all SortFields are checked, the internal Lucene docid is used to break it.
*/
public Sort(SortField... fields) {
+ this(null, fields);
+ }
+
+ /**
+ * Sets the sort to the given criteria in succession: the first SortField is checked first, but if
+ * it produces a tie, then the second SortField is used to break the tie, etc. Finally, if there
+ * is still a tie after all SortFields are checked, the internal Lucene docid is used to break it.
+ *
+ * @param parentField the name of a numeric doc values field that marks the last document of a
Review Comment:
I would rather not change `Sort` if possible. It's weird that it needs to know about a `parentField`, and IW should take care during static sort time (flush, merge) to validate that what it (IWC) knows as the parent field is consistent with the index-time sort?
##########
lucene/core/src/java/org/apache/lucene/index/Sorter.java:
##########
@@ -206,13 +209,28 @@ DocMap sort(LeafReader reader) throws IOException {
SortField[] fields = sort.getSort();
final IndexSorter.DocComparator[] comparators = new IndexSorter.DocComparator[fields.length];
+ Function<IndexSorter.DocComparator, IndexSorter.DocComparator> comparatorWrapper = in -> in;
+ LeafMetaData metaData = reader.getMetaData();
+ if (metaData.hasBlocks() && sort.getParentField() != null) {
+ BitSet parents =
+ BitSet.of(reader.getNumericDocValues(sort.getParentField()), reader.maxDoc());
+ comparatorWrapper =
+ in ->
+ (docID1, docID2) ->
+ in.compare(parents.nextSetBit(docID1), parents.nextSetBit(docID2));
+ }
+ assert metaData.hasBlocks() == false
Review Comment:
Real `if` -> `CorruptIndexException`?
##########
lucene/core/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java:
##########
@@ -231,7 +236,29 @@ long updateDocuments(
final int docsInRamBefore = numDocsInRAM;
boolean allDocsIndexed = false;
try {
- for (Iterable<? extends IndexableField> doc : docs) {
+ final Iterator<? extends Iterable<? extends IndexableField>> iterator = docs.iterator();
+ while (iterator.hasNext()) {
+ Iterable<? extends IndexableField> doc = iterator.next();
+ if (segmentInfo.getIndexSort() != null) {
+ String parentFieldName = segmentInfo.getIndexSort().getParentField();
+ if (parentFieldName != null) {
+ final NumericDocValuesField parentField;
+ if (iterator.hasNext() == false) {
+ int numChildren = numDocsInRAM - docsInRamBefore;
+ parentField = new NumericDocValuesField(parentFieldName, numChildren);
+ } else {
+ parentField = null;
+ }
+ doc = filterParentDocField(doc, parentFieldName, parentField);
+ } else if (iterator.hasNext() && indexVersionCreated >= Version.LUCENE_10_0_0.major) {
+ // sort is configured but parent field is missing, yet we have a doc-block
Review Comment:
So I think this means if you add a doc block, with only one document, it's OK to not have a `parentFieldName` configured, even if the index is created 10.0+? Maybe clarify that in the comment (why the `iterator.hasNext()` is being checked). It's sort of a degenerate usage of `addDocuments` that behaves like `addDocument`?
Hmm, except, it's allowed to add a parent with no children I think? And then we'll fail to catch the misuse?
##########
lucene/core/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java:
##########
@@ -231,7 +236,29 @@ long updateDocuments(
final int docsInRamBefore = numDocsInRAM;
boolean allDocsIndexed = false;
try {
- for (Iterable<? extends IndexableField> doc : docs) {
+ final Iterator<? extends Iterable<? extends IndexableField>> iterator = docs.iterator();
+ while (iterator.hasNext()) {
+ Iterable<? extends IndexableField> doc = iterator.next();
+ if (segmentInfo.getIndexSort() != null) {
+ String parentFieldName = segmentInfo.getIndexSort().getParentField();
+ if (parentFieldName != null) {
+ final NumericDocValuesField parentField;
+ if (iterator.hasNext() == false) {
+ int numChildren = numDocsInRAM - docsInRamBefore;
+ parentField = new NumericDocValuesField(parentFieldName, numChildren);
Review Comment:
Aha! You are recording `numChildren`, yay.
##########
lucene/core/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java:
##########
@@ -231,7 +236,29 @@ long updateDocuments(
final int docsInRamBefore = numDocsInRAM;
boolean allDocsIndexed = false;
try {
- for (Iterable<? extends IndexableField> doc : docs) {
+ final Iterator<? extends Iterable<? extends IndexableField>> iterator = docs.iterator();
+ while (iterator.hasNext()) {
+ Iterable<? extends IndexableField> doc = iterator.next();
+ if (segmentInfo.getIndexSort() != null) {
+ String parentFieldName = segmentInfo.getIndexSort().getParentField();
+ if (parentFieldName != null) {
+ final NumericDocValuesField parentField;
+ if (iterator.hasNext() == false) {
+ int numChildren = numDocsInRAM - docsInRamBefore;
+ parentField = new NumericDocValuesField(parentFieldName, numChildren);
+ } else {
+ parentField = null;
+ }
+ doc = filterParentDocField(doc, parentFieldName, parentField);
Review Comment:
OK so we are checking all child docs as well (that they do not illegally contain parent field), as well as parent doc (same, but also appending the parent field).
##########
lucene/core/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java:
##########
@@ -262,6 +290,44 @@ long updateDocuments(
}
}
+ private Iterable<? extends IndexableField> filterParentDocField(
Review Comment:
Can we rename this to `addParentDocField`? And as a side effect it is also validating that this field was not also added by the user? Maybe add that side effect above as a comment?
Edit: I see we call this for child docs too ... maybe rename to `maybeAddParentDocField`? `filter` sounds like it's gonna remove stuff.
##########
lucene/core/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java:
##########
@@ -262,6 +290,44 @@ long updateDocuments(
}
}
+ private Iterable<? extends IndexableField> filterParentDocField(
+ Iterable<? extends IndexableField> doc,
+ String parentFieldName,
+ NumericDocValuesField parentDocMarker) {
+ return () -> {
+ final Iterator<? extends IndexableField> first = doc.iterator();
+ return new Iterator<>() {
+ NumericDocValuesField additionalField = parentDocMarker;
+
+ @Override
+ public boolean hasNext() {
+ return first.hasNext() || additionalField != null;
+ }
+
+ @Override
+ public IndexableField next() {
+ if (first.hasNext()) {
+ IndexableField field = first.next();
+ if (parentFieldName.equals(field.name())
+ && DocValuesType.NUMERIC == field.fieldType().docValuesType()) {
+ throw new IllegalArgumentException(
+ "documents must not contain the parent doc values field \""
+ + parentFieldName
+ + "\"");
+ }
+ return field;
+ }
+ if (additionalField != null) {
+ IndexableField field = additionalField;
+ additionalField = null;
+ return field;
+ }
+ throw new NoSuchElementException();
Review Comment:
This might be hot-spotish? Can we allocate this once and always throw the same instance?
##########
lucene/core/src/java/org/apache/lucene/index/IndexingChain.java:
##########
@@ -219,15 +222,33 @@ private Sorter.DocMap maybeSortSegment(SegmentWriteState state) throws IOExcepti
}
LeafReader docValuesReader = getDocValuesLeafReader();
-
+ Function<IndexSorter.DocComparator, IndexSorter.DocComparator> comparatorWrapper = in -> in;
+
+ if (state.segmentInfo.getHasBlocks() && indexSort.getParentField() != null) {
+ final DocIdSetIterator readerValues =
+ docValuesReader.getNumericDocValues(indexSort.getParentField());
+ BitSet parents = BitSet.of(readerValues, state.segmentInfo.maxDoc());
+ comparatorWrapper =
+ in ->
+ (docID1, docID2) ->
+ in.compare(parents.nextSetBit(docID1), parents.nextSetBit(docID2));
+ }
+ assert state.segmentInfo.getHasBlocks() == false
Review Comment:
Maybe a real `if` --> `CorruptIndexException`?
##########
lucene/core/src/java/org/apache/lucene/index/IndexingChain.java:
##########
@@ -219,15 +222,33 @@ private Sorter.DocMap maybeSortSegment(SegmentWriteState state) throws IOExcepti
}
LeafReader docValuesReader = getDocValuesLeafReader();
-
+ Function<IndexSorter.DocComparator, IndexSorter.DocComparator> comparatorWrapper = in -> in;
+
+ if (state.segmentInfo.getHasBlocks() && indexSort.getParentField() != null) {
+ final DocIdSetIterator readerValues =
+ docValuesReader.getNumericDocValues(indexSort.getParentField());
+ BitSet parents = BitSet.of(readerValues, state.segmentInfo.maxDoc());
+ comparatorWrapper =
+ in ->
+ (docID1, docID2) ->
+ in.compare(parents.nextSetBit(docID1), parents.nextSetBit(docID2));
+ }
+ assert state.segmentInfo.getHasBlocks() == false
+ || indexSort.getParentField() != null
+ || indexCreatedVersionMajor < Version.LUCENE_10_0_0.major
+ : "parent field is not set but the index has blocks. indexCreatedVersionMajor: "
+ + indexCreatedVersionMajor;
List<IndexSorter.DocComparator> comparators = new ArrayList<>();
for (int i = 0; i < indexSort.getSort().length; i++) {
SortField sortField = indexSort.getSort()[i];
IndexSorter sorter = sortField.getIndexSorter();
if (sorter == null) {
throw new UnsupportedOperationException("Cannot sort index using sort field " + sortField);
}
- comparators.add(sorter.getDocComparator(docValuesReader, state.segmentInfo.maxDoc()));
+
+ IndexSorter.DocComparator docComparator =
Review Comment:
It looks like we are now relying on index sorting always being stable, because the child docs of one parent will always compare as equal to one another since we compare their parents?
Do we have any tests/confirmation all of Lucene's (static) Sort options are stable?
--
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: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Add support for index sorting with document blocks [lucene]
Posted by "s1monw (via GitHub)" <gi...@apache.org>.
s1monw commented on code in PR #12829:
URL: https://github.com/apache/lucene/pull/12829#discussion_r1423606084
##########
lucene/core/src/java/org/apache/lucene/index/IndexingChain.java:
##########
@@ -219,15 +222,33 @@ private Sorter.DocMap maybeSortSegment(SegmentWriteState state) throws IOExcepti
}
LeafReader docValuesReader = getDocValuesLeafReader();
-
+ Function<IndexSorter.DocComparator, IndexSorter.DocComparator> comparatorWrapper = in -> in;
+
+ if (state.segmentInfo.getHasBlocks() && indexSort.getParentField() != null) {
+ final DocIdSetIterator readerValues =
+ docValuesReader.getNumericDocValues(indexSort.getParentField());
+ BitSet parents = BitSet.of(readerValues, state.segmentInfo.maxDoc());
+ comparatorWrapper =
+ in ->
+ (docID1, docID2) ->
+ in.compare(parents.nextSetBit(docID1), parents.nextSetBit(docID2));
+ }
+ assert state.segmentInfo.getHasBlocks() == false
+ || indexSort.getParentField() != null
+ || indexCreatedVersionMajor < Version.LUCENE_10_0_0.major
+ : "parent field is not set but the index has blocks. indexCreatedVersionMajor: "
+ + indexCreatedVersionMajor;
List<IndexSorter.DocComparator> comparators = new ArrayList<>();
for (int i = 0; i < indexSort.getSort().length; i++) {
SortField sortField = indexSort.getSort()[i];
IndexSorter sorter = sortField.getIndexSorter();
if (sorter == null) {
throw new UnsupportedOperationException("Cannot sort index using sort field " + sortField);
}
- comparators.add(sorter.getDocComparator(docValuesReader, state.segmentInfo.maxDoc()));
+
+ IndexSorter.DocComparator docComparator =
Review Comment:
@msokolov This is basically what I had in my first version or this. There are a couple of issues with this:
- we can't execute arbitrary queries as a sort supplier since the datastructures inside DWPT don't support this
- in-fact we can only really access DV in such a fashion, we would likely be able with a non-trivial amount of work to walk a postinglist but executing a query ie. have a IndexReader on top of DWPT would be a lot of work.
- a custom comparator also needs a field, a type etc. that is more to configure and store in the index than just a field name that IW fully controls it's type and content.
I am still under the impression that you think this change dictates a type and name of a parent field for the application that uses Lucene. It's not. You can think of this as a purely internal field. You don't have to use it for you application or to model you block structure. It only marks the end of the block such that sort doesn't break it. It's basically an index level guarantee to the API guarantee we provide.
We do not need to model sub-blocks here since the order of the docs must not be changed also not by a sort? If it needs to be sorted then just within the block and that can / should happen before it's passed to the IW?
I hope this makes sense?
--
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: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Add support for index sorting with document blocks [lucene]
Posted by "s1monw (via GitHub)" <gi...@apache.org>.
s1monw commented on code in PR #12829:
URL: https://github.com/apache/lucene/pull/12829#discussion_r1440307876
##########
lucene/core/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java:
##########
@@ -245,10 +274,11 @@ long updateDocuments(
onNewDocOnRAM.run();
}
}
- allDocsIndexed = true;
- if (numDocsInRAM - docsInRamBefore > 1) {
+ final int numDocs = numDocsInRAM - docsInRamBefore;
+ if (numDocs > 1) {
segmentInfo.setHasBlocks();
Review Comment:
yes that is exactly right. I will add a test
--
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: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Add support for index sorting with document blocks [lucene]
Posted by "msokolov (via GitHub)" <gi...@apache.org>.
msokolov commented on code in PR #12829:
URL: https://github.com/apache/lucene/pull/12829#discussion_r1401297534
##########
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",
+ ex.getMessage());
+ },
+ () -> {
+ IllegalArgumentException ex =
+ expectThrows(
+ IllegalArgumentException.class,
+ () -> {
+ writer.addDocuments(Arrays.asList(new Document()));
+ });
+ assertEquals(
+ "the last document in the block must contain a numeric doc values field named: parent",
+ ex.getMessage());
+ });
+ Collections.shuffle(runnabels, random());
+ for (Runnable runnable : runnabels) {
+ runnable.run();
+ }
+ }
+ }
+ }
+
+ public void testIndexWithSortIsCongruent() 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)) {
+ Document child1 = new Document();
+ child1.add(new StringField("id", Integer.toString(1), Store.YES));
+ Document child2 = new Document();
+ child2.add(new StringField("id", Integer.toString(1), Store.YES));
+ Document parent = new Document();
+ parent.add(new StringField("id", Integer.toString(1), Store.YES));
+ parent.add(new NumericDocValuesField(parentField, 0));
Review Comment:
Is the value `0` significant in any way?
##########
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 think this will prevent us from handling multiple levels of nested child documents -- with a sort. I guess that would require multiple bitsets so you can do different kinds of joins. Seems kind of involved, but I think it is possible today?
##########
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",
+ ex.getMessage());
+ },
+ () -> {
+ IllegalArgumentException ex =
+ expectThrows(
+ IllegalArgumentException.class,
+ () -> {
+ writer.addDocuments(Arrays.asList(new Document()));
+ });
+ assertEquals(
+ "the last document in the block must contain a numeric doc values field named: parent",
+ ex.getMessage());
+ });
+ Collections.shuffle(runnabels, random());
+ for (Runnable runnable : runnabels) {
+ runnable.run();
+ }
+ }
+ }
+ }
+
+ public void testIndexWithSortIsCongruent() 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)) {
+ Document child1 = new Document();
+ child1.add(new StringField("id", Integer.toString(1), Store.YES));
+ Document child2 = new Document();
+ child2.add(new StringField("id", Integer.toString(1), Store.YES));
+ Document parent = new Document();
+ parent.add(new StringField("id", Integer.toString(1), Store.YES));
+ parent.add(new NumericDocValuesField(parentField, 0));
Review Comment:
I wonder if we could use the value to indicate different parent/child relations?
--
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: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Add support for index sorting with document blocks [lucene]
Posted by "s1monw (via GitHub)" <gi...@apache.org>.
s1monw commented on code in PR #12829:
URL: https://github.com/apache/lucene/pull/12829#discussion_r1403178782
##########
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",
+ ex.getMessage());
+ },
+ () -> {
+ IllegalArgumentException ex =
+ expectThrows(
+ IllegalArgumentException.class,
+ () -> {
+ writer.addDocuments(Arrays.asList(new Document()));
+ });
+ assertEquals(
+ "the last document in the block must contain a numeric doc values field named: parent",
+ ex.getMessage());
+ });
+ Collections.shuffle(runnabels, random());
+ for (Runnable runnable : runnabels) {
+ runnable.run();
+ }
+ }
+ }
+ }
+
+ public void testIndexWithSortIsCongruent() 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)) {
+ Document child1 = new Document();
+ child1.add(new StringField("id", Integer.toString(1), Store.YES));
+ Document child2 = new Document();
+ child2.add(new StringField("id", Integer.toString(1), Store.YES));
+ Document parent = new Document();
+ parent.add(new StringField("id", Integer.toString(1), Store.YES));
+ parent.add(new NumericDocValuesField(parentField, 0));
Review Comment:
no it has no meaning, we could add this field automatically at index time if a parent field is set on IWC or the sort and record the no. of children. If you wanna model multiple levels of nesting you can do that on top of the API. All we guarantee is that this block of docs is unchanged across merges. I don't think we should do more. you are free to use whatever marker you want to identify sub-roots. Yet, you can't use the parent field I think that is reserved for the top level.
One upside of having a single value for all parents is that is't very storage efficient.
--
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: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Add support for index sorting with document blocks [lucene]
Posted by "msokolov (via GitHub)" <gi...@apache.org>.
msokolov commented on PR #12829:
URL: https://github.com/apache/lucene/pull/12829#issuecomment-1830150503
@s1monw that makes sense. I think I was confusing index-time changes and query-time changes. This whole piece of functionality is a little confusing given how loosely coupled these things are!
--
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: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Add support for index sorting with document blocks [lucene]
Posted by "mikemccand (via GitHub)" <gi...@apache.org>.
mikemccand commented on PR #12829:
URL: https://github.com/apache/lucene/pull/12829#issuecomment-1875663308
> [add test and docs to make mike not staring at this forever](https://github.com/apache/lucene/pull/12829/commits/25e6da47f989675d310de5f319ff38088589b4d4)
HAHAHA
--
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: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Add support for index sorting with document blocks [lucene]
Posted by "mikemccand (via GitHub)" <gi...@apache.org>.
mikemccand commented on PR #12829:
URL: https://github.com/apache/lucene/pull/12829#issuecomment-1855769298
I opened https://github.com/mikemccand/luceneutil/issues/252 to try to measure the performance change of `addDocument` N times vs `addDocuments` once.
--
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: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Add support for index sorting with document blocks [lucene]
Posted by "s1monw (via GitHub)" <gi...@apache.org>.
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: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Add support for index sorting with document blocks [lucene]
Posted by "s1monw (via GitHub)" <gi...@apache.org>.
s1monw commented on code in PR #12829:
URL: https://github.com/apache/lucene/pull/12829#discussion_r1423637103
##########
lucene/core/src/java/org/apache/lucene/index/IndexingChain.java:
##########
@@ -219,15 +222,33 @@ private Sorter.DocMap maybeSortSegment(SegmentWriteState state) throws IOExcepti
}
LeafReader docValuesReader = getDocValuesLeafReader();
-
+ Function<IndexSorter.DocComparator, IndexSorter.DocComparator> comparatorWrapper = in -> in;
+
+ if (state.segmentInfo.getHasBlocks() && indexSort.getParentField() != null) {
+ final DocIdSetIterator readerValues =
+ docValuesReader.getNumericDocValues(indexSort.getParentField());
+ BitSet parents = BitSet.of(readerValues, state.segmentInfo.maxDoc());
+ comparatorWrapper =
+ in ->
+ (docID1, docID2) ->
+ in.compare(parents.nextSetBit(docID1), parents.nextSetBit(docID2));
+ }
+ assert state.segmentInfo.getHasBlocks() == false
+ || indexSort.getParentField() != null
+ || indexCreatedVersionMajor < Version.LUCENE_10_0_0.major
+ : "parent field is not set but the index has blocks. indexCreatedVersionMajor: "
+ + indexCreatedVersionMajor;
List<IndexSorter.DocComparator> comparators = new ArrayList<>();
for (int i = 0; i < indexSort.getSort().length; i++) {
SortField sortField = indexSort.getSort()[i];
IndexSorter sorter = sortField.getIndexSorter();
if (sorter == null) {
throw new UnsupportedOperationException("Cannot sort index using sort field " + sortField);
}
- comparators.add(sorter.getDocComparator(docValuesReader, state.segmentInfo.maxDoc()));
+
+ IndexSorter.DocComparator docComparator =
Review Comment:
I also thought a bit about other uses of this field that we should evaluate. One of the main things that make we worried is that fact that our delete API doesn't give the guarantees that it should IMO. Today you can just delete the parent without the children which will then in-turn merge adjacent blocks magically or erroneous together and searches will return broken results. With this field we can fix applying deletes to also delete all children if a parent is deleted which is the right thing to do in this case. There might be more usecases for this down to road mainly for index consistency.
--
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: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Add support for index sorting with document blocks [lucene]
Posted by "s1monw (via GitHub)" <gi...@apache.org>.
s1monw commented on PR #12829:
URL: https://github.com/apache/lucene/pull/12829#issuecomment-1882919819
@mikemccand I did another pass on it and change the wording. I think I know why you are confused and I tired to adress it. We use the exact same wording in the soft deletes case. I will work on this in a sep. issue
--
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: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Add support for index sorting with document blocks [lucene]
Posted by "mikemccand (via GitHub)" <gi...@apache.org>.
mikemccand commented on code in PR #12829:
URL: https://github.com/apache/lucene/pull/12829#discussion_r1442838857
##########
lucene/core/src/test/org/apache/lucene/index/TestAddIndexes.java:
##########
@@ -1937,4 +1937,97 @@ public void setMergeInfo(SegmentCommitInfo info) {
targetDir.close();
sourceDir.close();
}
+
+ public void testIllegalParentDocChange() throws Exception {
+ Directory dir1 = newDirectory();
+ IndexWriterConfig iwc1 = newIndexWriterConfig(new MockAnalyzer(random()));
+ iwc1.setParentField("foobar");
+ RandomIndexWriter w1 = new RandomIndexWriter(random(), dir1, iwc1);
+ Document parent = new Document();
+ w1.addDocuments(Arrays.asList(new Document(), new Document(), parent));
+ w1.commit();
+ w1.addDocuments(Arrays.asList(new Document(), new Document(), parent));
+ w1.commit();
+ // so the index sort is in fact burned into the index:
+ w1.forceMerge(1);
+ w1.close();
+
+ Directory dir2 = newDirectory();
+ IndexWriterConfig iwc2 = newIndexWriterConfig(new MockAnalyzer(random()));
+ iwc2.setParentField("foo");
+ RandomIndexWriter w2 = new RandomIndexWriter(random(), dir2, iwc2);
+
+ IndexReader r1 = DirectoryReader.open(dir1);
+ String message =
+ expectThrows(
+ IllegalArgumentException.class,
+ () -> {
+ w2.addIndexes((SegmentReader) getOnlyLeafReader(r1));
+ })
+ .getMessage();
+ assertEquals(
+ "cannot configure [foo] as parent document field ; this index uses [foobar] as parent document field already",
Review Comment:
See I think this exception message is backwards :) Shouldn't it be:
```
cannot configure [foobar] as parent document field ; this index uses [foo] as parent document field already
```
I.e. "this index" is referring to `dir2`/`w2` (the index into which we are adding an external index), and it is configured to use `foo` as the parent field, while the incoming index via `addIndexes` (`dir1`) is attempting (illegally) to change that to `foobar`?
Edit: OK I think this all comes down to `this index` being super confusing to me :) If it's referring to the incoming (newly added) index via addIndexes, the message makes sense. But I would think `this index` means the one you opened with IW...
##########
lucene/core/src/java/org/apache/lucene/index/FieldInfos.java:
##########
@@ -78,6 +80,7 @@ public FieldInfos(FieldInfo[] infos) {
boolean hasPointValues = false;
boolean hasVectorValues = false;
String softDeletesField = null;
+ String parentField = null;
Review Comment:
Maybe fix these silly pointless initializers ^^?
This `FieldInfos.java` is some of the oldest, most "pristine"/"untouched" code in Lucene ;) You can almost count the tree rings ...
##########
lucene/core/src/test/org/apache/lucene/index/TestAddIndexes.java:
##########
@@ -1937,4 +1937,97 @@ public void setMergeInfo(SegmentCommitInfo info) {
targetDir.close();
sourceDir.close();
}
+
+ public void testIllegalParentDocChange() throws Exception {
+ Directory dir1 = newDirectory();
+ IndexWriterConfig iwc1 = newIndexWriterConfig(new MockAnalyzer(random()));
+ iwc1.setParentField("foobar");
+ RandomIndexWriter w1 = new RandomIndexWriter(random(), dir1, iwc1);
+ Document parent = new Document();
+ w1.addDocuments(Arrays.asList(new Document(), new Document(), parent));
+ w1.commit();
+ w1.addDocuments(Arrays.asList(new Document(), new Document(), parent));
+ w1.commit();
+ // so the index sort is in fact burned into the index:
+ w1.forceMerge(1);
+ w1.close();
+
+ Directory dir2 = newDirectory();
+ IndexWriterConfig iwc2 = newIndexWriterConfig(new MockAnalyzer(random()));
+ iwc2.setParentField("foo");
+ RandomIndexWriter w2 = new RandomIndexWriter(random(), dir2, iwc2);
+
+ IndexReader r1 = DirectoryReader.open(dir1);
+ String message =
+ expectThrows(
+ IllegalArgumentException.class,
+ () -> {
+ w2.addIndexes((SegmentReader) getOnlyLeafReader(r1));
+ })
+ .getMessage();
+ assertEquals(
+ "cannot configure [foo] as parent document field ; this index uses [foobar] as parent document field already",
+ message);
+
+ message =
+ expectThrows(
+ IllegalArgumentException.class,
+ () -> {
+ w2.addIndexes(dir1);
+ })
+ .getMessage();
+ assertEquals(
+ "cannot configure [foo] as parent document field ; this index uses [foobar] as parent document field already",
Review Comment:
Same here?
##########
lucene/core/src/java/org/apache/lucene/index/FieldInfos.java:
##########
@@ -437,6 +488,33 @@ private void verifySoftDeletedFieldName(String fieldName, boolean isSoftDeletesF
}
}
+ private void verifyParentFieldName(String fieldName, boolean isParentField) {
+ if (isParentField) {
+ if (parentFieldName == null) {
+ throw new IllegalArgumentException(
+ "this index has ["
+ + fieldName
+ + "] as parent document field already but parent document field is not configured in IWC");
+ } else if (fieldName.equals(parentFieldName) == false) {
+ throw new IllegalArgumentException(
+ "cannot configure ["
+ + parentFieldName
+ + "] as parent document field ; this index uses ["
+ + fieldName
Review Comment:
> I would like to find a way that users don't have to specify these fieldnames altogether but that should be a follow up
Yeah +1 to defer.
Phew, I fired up a GitHub workspace to spelunk the code/PR better! I think (maybe?) I understand what's going on and my confusion! I need more caffeine now ...
I think this code is supposed to only catch the `addIndexes` mismatch case? Because, by design, if user is indexing documents, they cannot tickle this code -- the `parentFieldName` (from IWC) and the newly born `FieldInfo` (in-memory DWPT segment) will also use IWC's configured parent field, so these ifs should never trigger from simply indexing documents?
Maybe we can rename `parentFieldName` to `iwcParentFieldName` making its provenance clear? Then, by contrast, it's more clear that `fieldName` is the new foreign entity that must be validated against IWC's config.
And then I find `this index` super confusing -- in the test case it seems to refer to the incoming index (via `addIndexes`) and not to the currently open index that your `IndexWriter` is pointing to?
How about changing the wording for all of these exceptions to something like `the current index is configured with parentName=X; cannot add external index with parentName=Y` or so?
##########
lucene/core/src/java/org/apache/lucene/index/FieldInfos.java:
##########
@@ -132,6 +135,13 @@ public FieldInfos(FieldInfo[] infos) {
}
softDeletesField = info.name;
}
+ if (info.isParentField()) {
+ if (parentField != null && parentField.equals(info.name) == false) {
+ throw new IllegalArgumentException(
+ "multiple parent fields [" + info.name + ", " + parentField + "]");
Review Comment:
Can we improve this wording @s1monw ^^? It is confusing because it does not actually say specifically what is wrong (that you must have only one parent field).
--
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: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Add support for index sorting with document blocks [lucene]
Posted by "s1monw (via GitHub)" <gi...@apache.org>.
s1monw commented on code in PR #12829:
URL: https://github.com/apache/lucene/pull/12829#discussion_r1419203464
##########
lucene/backward-codecs/src/test/org/apache/lucene/backward_index/TestBackwardsCompatibility.java:
##########
@@ -2164,6 +2166,83 @@ public void testSortedIndex() throws Exception {
}
}
+ public void testSortedIndexAddDocBlocks() throws Exception {
+ for (String name : oldSortedNames) {
+ Path path = createTempDir("sorted");
+ InputStream resource = TestBackwardsCompatibility.class.getResourceAsStream(name + ".zip");
+ assertNotNull("Sorted index index " + name + " not found", resource);
+ TestUtil.unzip(resource, path);
+
+ try (Directory dir = newFSDirectory(path)) {
+ final Sort sort;
+ try (DirectoryReader reader = DirectoryReader.open(dir)) {
+ assertEquals(1, reader.leaves().size());
+ sort = reader.leaves().get(0).reader().getMetaData().getSort();
+ assertNotNull(sort);
+ searchExampleIndex(reader);
+ }
+ // open writer
+ try (IndexWriter writer =
+ new IndexWriter(
+ dir,
+ newIndexWriterConfig(new MockAnalyzer(random()))
+ .setOpenMode(OpenMode.APPEND)
+ .setIndexSort(sort)
+ .setMergePolicy(newLogMergePolicy()))) {
+ // add 10 docs
+ for (int i = 0; i < 10; i++) {
+ Document child = new Document();
+ child.add(new StringField("relation", "child", Field.Store.NO));
+ child.add(new StringField("bid", "" + i, Field.Store.NO));
+ child.add(new NumericDocValuesField("dateDV", i));
+ Document parent = new Document();
+ parent.add(new StringField("relation", "parent", Field.Store.NO));
+ parent.add(new StringField("bid", "" + i, Field.Store.NO));
+ parent.add(new NumericDocValuesField("dateDV", i));
+ writer.addDocuments(Arrays.asList(child, child, parent));
+ if (random().nextBoolean()) {
+ writer.flush();
+ }
+ }
+ if (random().nextBoolean()) {
+ writer.forceMerge(1);
+ }
+ writer.commit();
+ try (IndexReader reader = DirectoryReader.open(dir)) {
+ IndexSearcher searcher = new IndexSearcher(reader);
+ for (int i = 0; i < 10; i++) {
+ TopDocs children =
+ searcher.search(
+ new BooleanQuery.Builder()
+ .add(
+ new TermQuery(new Term("relation", "child")),
+ BooleanClause.Occur.MUST)
+ .add(new TermQuery(new Term("bid", "" + i)), BooleanClause.Occur.MUST)
+ .build(),
+ 2);
+ TopDocs parents =
+ searcher.search(
+ new BooleanQuery.Builder()
+ .add(
+ new TermQuery(new Term("relation", "parent")),
+ BooleanClause.Occur.MUST)
+ .add(new TermQuery(new Term("bid", "" + i)), BooleanClause.Occur.MUST)
+ .build(),
+ 2);
+ assertEquals(2, children.totalHits.value);
+ assertEquals(1, parents.totalHits.value);
+ // make sure it's sorted
+ assertEquals(children.scoreDocs[0].doc + 1, children.scoreDocs[1].doc);
+ assertEquals(children.scoreDocs[1].doc + 1, parents.scoreDocs[0].doc);
+ }
+ }
+ }
+ // This will confirm the docs are really sorted
+ TestUtil.checkIndex(dir);
Review Comment:
yeah I did that already if you have more ideas, pls lemme know
--
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: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Add support for index sorting with document blocks [lucene]
Posted by "s1monw (via GitHub)" <gi...@apache.org>.
s1monw commented on code in PR #12829:
URL: https://github.com/apache/lucene/pull/12829#discussion_r1419210065
##########
lucene/core/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java:
##########
@@ -262,6 +290,44 @@ long updateDocuments(
}
}
+ private Iterable<? extends IndexableField> filterParentDocField(
+ Iterable<? extends IndexableField> doc,
+ String parentFieldName,
+ NumericDocValuesField parentDocMarker) {
+ return () -> {
+ final Iterator<? extends IndexableField> first = doc.iterator();
+ return new Iterator<>() {
Review Comment:
I changed this it to a slightly different approach, lemme know what you think
--
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: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Add support for index sorting with document blocks [lucene]
Posted by "s1monw (via GitHub)" <gi...@apache.org>.
s1monw commented on PR #12829:
URL: https://github.com/apache/lucene/pull/12829#issuecomment-1862391122
@mikemccand @jpountz I updated this PR and moved everything to FielInfo / IWC. I think it's ready. the only thing that I'd like to discuss is that we are currently recording the number of children in the DV field. I don't think we should do that unless we have a good reason. Instead i'd like to index `-1` into it to keep that for a later version of lucene if we have a reason for it. that would also make this field essentially a bitset on the DV codec end.
From a testing perspective, I 'd like to enable this randomly in `RIW` but that requires some changes and I'd rather do that in a followup which is easier to review.
--
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: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Add support for index sorting with document blocks [lucene]
Posted by "s1monw (via GitHub)" <gi...@apache.org>.
s1monw commented on code in PR #12829:
URL: https://github.com/apache/lucene/pull/12829#discussion_r1437134740
##########
lucene/core/src/java/org/apache/lucene/index/FieldInfos.java:
##########
@@ -188,6 +200,26 @@ public static FieldInfos getMergedFieldInfos(IndexReader reader) {
}
}
+ private static String getAndValidateParentField(List<LeafReaderContext> leaves) {
+ boolean set = false;
+ String theField = null;
+ for (LeafReaderContext ctx : leaves) {
+ String field = ctx.reader().getFieldInfos().getParentField();
+ if (set && Objects.equals(field, theField) == false) {
+ throw new IllegalStateException(
Review Comment:
yeah I think so too
--
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: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Add support for index sorting with document blocks [lucene]
Posted by "mikemccand (via GitHub)" <gi...@apache.org>.
mikemccand commented on code in PR #12829:
URL: https://github.com/apache/lucene/pull/12829#discussion_r1440776709
##########
lucene/core/src/java/org/apache/lucene/index/FieldInfos.java:
##########
@@ -437,6 +488,33 @@ private void verifySoftDeletedFieldName(String fieldName, boolean isSoftDeletesF
}
}
+ private void verifyParentFieldName(String fieldName, boolean isParentField) {
+ if (isParentField) {
+ if (parentFieldName == null) {
+ throw new IllegalArgumentException(
+ "this index has ["
+ + fieldName
+ + "] as parent document field already but parent document field is not configured in IWC");
Review Comment:
Same here? `parentFieldName` was derived from the segments in the current index (not set), and now a document (current IWC) is trying to set `fieldName` as the parent field?
--
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: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Add support for index sorting with document blocks [lucene]
Posted by "msokolov (via GitHub)" <gi...@apache.org>.
msokolov commented on code in PR #12829:
URL: https://github.com/apache/lucene/pull/12829#discussion_r1424209861
##########
lucene/core/src/java/org/apache/lucene/index/IndexingChain.java:
##########
@@ -219,15 +222,33 @@ private Sorter.DocMap maybeSortSegment(SegmentWriteState state) throws IOExcepti
}
LeafReader docValuesReader = getDocValuesLeafReader();
-
+ Function<IndexSorter.DocComparator, IndexSorter.DocComparator> comparatorWrapper = in -> in;
+
+ if (state.segmentInfo.getHasBlocks() && indexSort.getParentField() != null) {
+ final DocIdSetIterator readerValues =
+ docValuesReader.getNumericDocValues(indexSort.getParentField());
+ BitSet parents = BitSet.of(readerValues, state.segmentInfo.maxDoc());
+ comparatorWrapper =
+ in ->
+ (docID1, docID2) ->
+ in.compare(parents.nextSetBit(docID1), parents.nextSetBit(docID2));
+ }
+ assert state.segmentInfo.getHasBlocks() == false
+ || indexSort.getParentField() != null
+ || indexCreatedVersionMajor < Version.LUCENE_10_0_0.major
+ : "parent field is not set but the index has blocks. indexCreatedVersionMajor: "
+ + indexCreatedVersionMajor;
List<IndexSorter.DocComparator> comparators = new ArrayList<>();
for (int i = 0; i < indexSort.getSort().length; i++) {
SortField sortField = indexSort.getSort()[i];
IndexSorter sorter = sortField.getIndexSorter();
if (sorter == null) {
throw new UnsupportedOperationException("Cannot sort index using sort field " + sortField);
}
- comparators.add(sorter.getDocComparator(docValuesReader, state.segmentInfo.maxDoc()));
+
+ IndexSorter.DocComparator docComparator =
Review Comment:
Thanks for addl info @simonw. your point about the complication of arbitrary query execution from inside indexing chain makes sense. I think the approach makes sense to me
##########
lucene/core/src/java/org/apache/lucene/index/IndexingChain.java:
##########
@@ -1512,4 +1557,77 @@ void assertSameSchema(FieldInfo fi) {
assertSame("point num bytes", fi.getPointNumBytes(), pointNumBytes);
}
}
+
+ /**
+ * Wraps the given field in a reserved field and registers it as reserved. Only DWPT should do
+ * this to mark fields as private / reserved to prevent this fieldname to be used from the outside
Review Comment:
I get that we are recording the name so it cannot be created with a different type, and indeed prevent it from being added to a document except by IndexingChain -- are there any other restrictions on the use of the field? Could we clear up the javadoc to be more explicit? I think eg I can still get a DV iterator over this field and read its values from "outside". Maybe we could say "prevent this fieldname from being used when writing documents ..."?
--
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: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Add support for index sorting with document blocks [lucene]
Posted by "s1monw (via GitHub)" <gi...@apache.org>.
s1monw commented on PR #12829:
URL: https://github.com/apache/lucene/pull/12829#issuecomment-1829488114
@mikemccand @jpountz thanks for your ideas. I'd love to flash this out more before we add anything we write to the index. Today we'd only use this for sorting but if that field can be useful to speed up or improve searching I am happy to extend this further.
My suggestion here is to move the parentField away from sort to IWC and if you configure it we automatically add this field in DWPT to every parent document. We can then also check if it's set and a sort is used and fail if a block is indexed and it's unset. That would allow us to gradually add this in 9.x and require it for sorting in 10? That way I can also go ahead and set the number of children as the value for that field. WDYT?
@msokolov there is no reduction of features here. you can do all the things you have done before except of re-sorting the do cuments within a block. This is a API guarantee that we try to fix here. You can still add another field to each doc specifying which hierarchy level it belongs to and then do `books -> chapters -> paragraphs` whatever relations to that. All we try to prevent is that the API guarantee is broken up due to a sort etc. Hope that helps?
--
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: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Add support for index sorting with document blocks [lucene]
Posted by "s1monw (via GitHub)" <gi...@apache.org>.
s1monw commented on PR #12829:
URL: https://github.com/apache/lucene/pull/12829#issuecomment-1837464516
@mikemccand @jpountz I went down a hybrid way. This change now only requires the user to specify the field name and IW adds it to the last doc in the block if it's configured. I will for sure add some more tests to this once we settled on the approach. The only think I am torn on is, if we set the num of children as a value for the DV field then I guess we should have a good usecase for that?
--
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: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Add support for index sorting with document blocks [lucene]
Posted by "s1monw (via GitHub)" <gi...@apache.org>.
s1monw commented on code in PR #12829:
URL: https://github.com/apache/lucene/pull/12829#discussion_r1419505134
##########
lucene/core/src/java/org/apache/lucene/search/Sort.java:
##########
@@ -59,10 +61,28 @@ public Sort() {
* is still a tie after all SortFields are checked, the internal Lucene docid is used to break it.
*/
public Sort(SortField... fields) {
+ this(null, fields);
+ }
+
+ /**
+ * Sets the sort to the given criteria in succession: the first SortField is checked first, but if
+ * it produces a tie, then the second SortField is used to break the tie, etc. Finally, if there
+ * is still a tie after all SortFields are checked, the internal Lucene docid is used to break it.
+ *
+ * @param parentField the name of a numeric doc values field that marks the last document of a
Review Comment:
@mikemccand do you mean we should rather make this a property of IWC rather than sort? That would be no issue. I used sort here since it's the only thing that is using this?
--
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: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Add support for index sorting with document blocks [lucene]
Posted by "s1monw (via GitHub)" <gi...@apache.org>.
s1monw commented on code in PR #12829:
URL: https://github.com/apache/lucene/pull/12829#discussion_r1419216698
##########
lucene/core/src/java/org/apache/lucene/index/IndexingChain.java:
##########
@@ -219,15 +222,33 @@ private Sorter.DocMap maybeSortSegment(SegmentWriteState state) throws IOExcepti
}
LeafReader docValuesReader = getDocValuesLeafReader();
-
+ Function<IndexSorter.DocComparator, IndexSorter.DocComparator> comparatorWrapper = in -> in;
+
+ if (state.segmentInfo.getHasBlocks() && indexSort.getParentField() != null) {
+ final DocIdSetIterator readerValues =
+ docValuesReader.getNumericDocValues(indexSort.getParentField());
+ BitSet parents = BitSet.of(readerValues, state.segmentInfo.maxDoc());
+ comparatorWrapper =
+ in ->
+ (docID1, docID2) ->
+ in.compare(parents.nextSetBit(docID1), parents.nextSetBit(docID2));
+ }
+ assert state.segmentInfo.getHasBlocks() == false
+ || indexSort.getParentField() != null
+ || indexCreatedVersionMajor < Version.LUCENE_10_0_0.major
+ : "parent field is not set but the index has blocks. indexCreatedVersionMajor: "
+ + indexCreatedVersionMajor;
List<IndexSorter.DocComparator> comparators = new ArrayList<>();
for (int i = 0; i < indexSort.getSort().length; i++) {
SortField sortField = indexSort.getSort()[i];
IndexSorter sorter = sortField.getIndexSorter();
if (sorter == null) {
throw new UnsupportedOperationException("Cannot sort index using sort field " + sortField);
}
- comparators.add(sorter.getDocComparator(docValuesReader, state.segmentInfo.maxDoc()));
+
+ IndexSorter.DocComparator docComparator =
Review Comment:
@jpountz can you answer this?
--
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: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Add support for index sorting with document blocks [lucene]
Posted by "jpountz (via GitHub)" <gi...@apache.org>.
jpountz commented on code in PR #12829:
URL: https://github.com/apache/lucene/pull/12829#discussion_r1419268112
##########
lucene/core/src/java/org/apache/lucene/index/IndexingChain.java:
##########
@@ -219,15 +222,33 @@ private Sorter.DocMap maybeSortSegment(SegmentWriteState state) throws IOExcepti
}
LeafReader docValuesReader = getDocValuesLeafReader();
-
+ Function<IndexSorter.DocComparator, IndexSorter.DocComparator> comparatorWrapper = in -> in;
+
+ if (state.segmentInfo.getHasBlocks() && indexSort.getParentField() != null) {
+ final DocIdSetIterator readerValues =
+ docValuesReader.getNumericDocValues(indexSort.getParentField());
+ BitSet parents = BitSet.of(readerValues, state.segmentInfo.maxDoc());
+ comparatorWrapper =
+ in ->
+ (docID1, docID2) ->
+ in.compare(parents.nextSetBit(docID1), parents.nextSetBit(docID2));
+ }
+ assert state.segmentInfo.getHasBlocks() == false
+ || indexSort.getParentField() != null
+ || indexCreatedVersionMajor < Version.LUCENE_10_0_0.major
+ : "parent field is not set but the index has blocks. indexCreatedVersionMajor: "
+ + indexCreatedVersionMajor;
List<IndexSorter.DocComparator> comparators = new ArrayList<>();
for (int i = 0; i < indexSort.getSort().length; i++) {
SortField sortField = indexSort.getSort()[i];
IndexSorter sorter = sortField.getIndexSorter();
if (sorter == null) {
throw new UnsupportedOperationException("Cannot sort index using sort field " + sortField);
}
- comparators.add(sorter.getDocComparator(docValuesReader, state.segmentInfo.maxDoc()));
+
+ IndexSorter.DocComparator docComparator =
Review Comment:
It's been a long time so I don't know if/where this is tested, I just know that we need stability for other reasons, e.g. to preserve some merging optimizations by having runs of doc IDs that come from the same segment that are as long as possible.
--
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: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Add support for index sorting with document blocks [lucene]
Posted by "s1monw (via GitHub)" <gi...@apache.org>.
s1monw commented on code in PR #12829:
URL: https://github.com/apache/lucene/pull/12829#discussion_r1435809808
##########
lucene/core/src/java/org/apache/lucene/index/FieldInfos.java:
##########
@@ -437,6 +486,31 @@ private void verifySoftDeletedFieldName(String fieldName, boolean isSoftDeletesF
}
}
+ private void verifyParentFieldName(String fieldName, boolean isParentField) {
+ if (isParentField) {
+ if (parentFieldName == null) {
+ throw new IllegalArgumentException(
+ "this index has ["
+ + fieldName
+ + "] as parent document field already but parent document field is not configured in IWC");
+ } else if (fieldName.equals(parentFieldName) == false) {
+ throw new IllegalArgumentException(
+ "cannot configure ["
+ + parentFieldName
+ + "] as parent document field ; this index uses ["
+ + fieldName
+ + "] as parent document field already");
+ }
+ } else if (fieldName.equals(parentFieldName)) {
+ throw new IllegalArgumentException(
+ "cannot configure ["
+ + parentFieldName
+ + "] as parent document field ; this index uses ["
Review Comment:
so my way of thinking is that `parentFieldName` is coming from IWC essentially but it's not there. Pretty much the same thing as the softdeletes equivalent above.
--
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: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org