66 * | __/\ V /| | || (_| | |_| | |_) |
77 * \___| \_/ |_|\__\__,_|____/|____/
88 *
9- * Copyright (c) 2023-2024
9+ * Copyright (c) 2023-2025
1010 *
1111 * Licensed under the Business Source License, Version 1.1 (the "License");
1212 * you may not use this file except in compliance with the License.
4646import io .evitadb .index .EntityIndex ;
4747import io .evitadb .index .attribute .FilterIndex ;
4848import io .evitadb .index .attribute .UniqueIndex ;
49+ import io .evitadb .index .bitmap .Bitmap ;
4950
5051import javax .annotation .Nonnull ;
5152import java .util .Objects ;
@@ -243,7 +244,10 @@ private static Formula translateIsNotNull(
243244 attributeKey ,
244245 filterByVisitor .applyOnGlobalUniqueIndexes (
245246 globalAttributeSchema ,
246- index -> new ConstantFormula (index .getRecordIds (filterByVisitor .getEntityType ()))
247+ index -> {
248+ final Bitmap recordIds = index .getRecordIds (filterByVisitor .getEntityType ());
249+ return recordIds .isEmpty () ? EmptyFormula .INSTANCE : new ConstantFormula (recordIds );
250+ }
247251 )
248252 );
249253 } else if (scopes .stream ().anyMatch (attributeDefinition ::isUniqueInScope )) {
@@ -252,7 +256,10 @@ private static Formula translateIsNotNull(
252256 attributeKey ,
253257 filterByVisitor .applyOnUniqueIndexes (
254258 attributeDefinition ,
255- index -> new ConstantFormula (index .getRecordIds ())
259+ index -> {
260+ final Bitmap recordIds = index .getRecordIds ();
261+ return recordIds .isEmpty () ? EmptyFormula .INSTANCE : new ConstantFormula (recordIds );
262+ }
256263 )
257264 );
258265 } else {
0 commit comments