Skip to content

Commit 8546989

Browse files
committed
[fix] small improvements in LuceneIndexWorker
1 parent 2b912f1 commit 8546989

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

extensions/indexes/lucene/src/main/java/org/exist/indexing/lucene/LuceneIndexWorker.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,12 +1162,13 @@ else if (field == null) {
11621162
*/
11631163
public static LuceneConfig getLuceneConfig(DBBroker broker, DocumentSet docs) {
11641164
for (Iterator<Collection> i = docs.getCollectionIterator(); i.hasNext(); ) {
1165-
Collection collection = i.next();
1166-
IndexSpec idxConf = collection.getIndexConfiguration(broker);
1167-
if (idxConf != null) {
1168-
LuceneConfig config = (LuceneConfig) idxConf.getCustomIndexSpec(LuceneIndex.ID);
1169-
if (config != null) {
1170-
return config;
1165+
try (Collection collection = i.next();) {
1166+
IndexSpec idxConf = collection.getIndexConfiguration(broker);
1167+
if (idxConf != null) {
1168+
LuceneConfig config = (LuceneConfig) idxConf.getCustomIndexSpec(LuceneIndex.ID);
1169+
if (config != null) {
1170+
return config;
1171+
}
11711172
}
11721173
}
11731174
}
@@ -1423,7 +1424,7 @@ private void write() {
14231424
// store the node id
14241425
int nodeIdLen = pending.nodeId.size();
14251426
byte[] data = new byte[nodeIdLen + 2];
1426-
ByteConversion.shortToByte((short) pending.nodeId.units(), data, 0);
1427+
ByteConversion.shortToByteH((short) pending.nodeId.units(), data, 0);
14271428
pending.nodeId.serialize(data, 2);
14281429
fNodeId.setBytesValue(data);
14291430
doc.add(fNodeId);
@@ -1438,10 +1439,11 @@ private void write() {
14381439
// the text content is indexed in a field using either
14391440
// the qname of the element or attribute or the field
14401441
// name defined in the configuration
1441-
if (pending.idxConf.isNamed())
1442+
if (pending.idxConf.isNamed()) {
14421443
contentField = pending.idxConf.getName();
1443-
else
1444+
} else {
14441445
contentField = LuceneUtil.encodeQName(pending.qname, index.getBrokerPool().getSymbols());
1446+
}
14451447

14461448
Field fld = new TextField(contentField, pending.text.toString(), Field.Store.NO);
14471449

@@ -1454,6 +1456,7 @@ private void write() {
14541456
if (pending.idxConf.getAnalyzer() == null) {
14551457
writer.addDocument(config.facetsConfig.build(index.getTaxonomyWriter(), doc));
14561458
} else {
1459+
// FIXME: re-enable custom analyzers again
14571460
LOG.warn("Custom analyzer for pending doc is not supported in Lucene 10 upgrade yet. Using default.");
14581461
writer.addDocument(config.facetsConfig.build(index.getTaxonomyWriter(), doc));
14591462
}

0 commit comments

Comments
 (0)