Skip to content
Permalink
Browse files
OAK-9724 Handle duplicate functions gracefully in indexing
  • Loading branch information
thomasmueller committed Mar 16, 2022
1 parent b165ce9 commit 65a4f80242c610829a9bbda934040eca14b0f8e3
Showing 1 changed file with 12 additions and 0 deletions.
@@ -56,9 +56,15 @@ public class LuceneDocumentMaker extends FulltextDocumentMaker<Document> {
private static final Logger log = LoggerFactory.getLogger(LuceneDocumentMaker.class);

private static final String DYNAMIC_BOOST_SPLIT_REGEX = "[:/]";

// warn once every 10 seconds at most
private static final long DUPLICATE_WARNING_INTERVAL_MS = 10 * 1000;

private final FacetsConfigProvider facetsConfigProvider;
private final IndexAugmentorFactory augmentorFactory;

// when did we warn (static, as we construct new objects quite often)
private static long lastDuplicateWarning;

public LuceneDocumentMaker(IndexDefinition definition,
IndexDefinition.IndexingRule indexingRule,
@@ -286,6 +292,12 @@ protected boolean indexTypeOrderedFields(Document doc, String pname, int tag, Pr
if (doc.getField(f.name()) == null) {
doc.add(f);
fieldAdded = true;
} else {
long now = System.currentTimeMillis();
if (now > lastDuplicateWarning + DUPLICATE_WARNING_INTERVAL_MS) {
log.warn("Duplicate value for ordered field {}; ignoring. Possibly duplicate index definition.", f.name());
lastDuplicateWarning = now;
}
}
}
} catch (Exception e) {

0 comments on commit 65a4f80

Please sign in to comment.