public void indexDocument(int docId, Predicate predicate) {
        if (documentIdCounter == Integer.MAX_VALUE) {
            throw new IllegalStateException("Index is full, max number of documents is: " + Integer.MAX_VALUE);
        } else if (seenIds.contains(docId)) {
            throw new IllegalArgumentException("Document id is already in use: " + docId);
        } else if (isNeverMatchingDocument(predicate)) {
            return;
        }
        seenIds.add(docId);
        predicate = optimizer.optimizePredicate(predicate);
        int internalId = documentIdCounter++;
        if (isAlwaysMatchingDocument(predicate)) {
            indexZeroConstraintDocument(internalId);
        } else {
            indexDocument(internalId, PredicateTreeAnnotator.createPredicateTreeAnnotations(predicate));
        }
    }
@Test
    void requireThatIndexingMultiDocumentsWithSameIdThrowsException() {
        assertThrows(IllegalArgumentException.class, () -> {
            PredicateIndexBuilder builder = new PredicateIndexBuilder(2);
            builder.indexDocument(1, Predicate.fromString("a in ['b']"));
            builder.indexDocument(1, Predicate.fromString("c in ['d']"));
        });
    }