The trick is to use str
inside the contains
.
This query gives the expected result:
select ?item ?img
{
hint:Query hint:maxParallel 400 .
hint:Query hint:chunkSize 8000 .
?item wdt:P18 ?img .
filter contains(str(?img), "Montage")
}
Another way to achieve this is to set hint:Query hint:regexMatchNonString true
and then use a normal regex.
(Huge thanks to Stanislav Kralin who found all this)