Based on the previous question:
Neo4j Cypher query structure and performance optimization Neo4j Cypher node filtering by pattern comprehension
finally I have re
So for the reason this only works with 1 key, lets go over what one WHERE ALL is doing when there is 2 keys.
WITH inFilters = {3153=30, 3151=Two}
....
WHERE ALL(key IN keys({equalFilters})
WHERE id(equalFilterCharacteristic) = toInt(key)
AND equalFilterValue.value = ({equalFilters}[key]))
Is equivalent to
WHERE id(equalFilterCharacteristic) = toInt(3153)
AND equalFilterValue.value = ({equalFilters}[3153])
AND id(equalFilterCharacteristic) = toInt(3151)
AND equalFilterValue.value = ({equalFilters}[3151])
And the problem there is that now we are checking that the node id of equalFilterCharacteristic is equal to 3153 AND 3151 at the same time, for each and every equalFilterCharacteristic. Since Neo4j only uses real numbers for the node ids, the above statement basically ends up reducing to an expensive WHERE FALSE when there is more than 1 key. So WHERE ALL can never be true in the above case. WHERE ANY however will evaluate to true if at least 1 check-group is true, and would be equivalent to
WHERE (
id(equalFilterCharacteristic) = toInt(3153)
AND equalFilterValue.value = ({equalFilters}[3153])
)
OR
(
id(equalFilterCharacteristic) = toInt(3151)
AND equalFilterValue.value = ({equalFilters}[3151])
)
Of course, since you know the key you are trying to match, you can skip the ALL and just do (don't think you need toInt() on id(), but id() is a long)
WHERE equalFilterValue.value = ({equalFilters}[id(equalFilterCharacteristic)])