504 is a timeout response code; implying search query is taking too long to run. You turn on debug logs using /system/console/slinglog on package org.apache.jackrabbit.oak.query and see the query being run, the query plan & index being used to serve results. Usually /content/dam path is part of the ...