Tom Blackford created OAK-12014:
-----------------------------------
Summary: Oak Elastic 'more_like_this' queries do not include path
restriction
Key: OAK-12014
URL: https://issues.apache.org/jira/browse/OAK-12014
Project: Jackrabbit Oak
Issue Type: Bug
Reporter: Tom Blackford
For a query like -
{code}
/jcr:root/content/dam/folder1/subFolder1//element(*, dam:Asset)[(rep:similar(.,
'/content/dam/myasset.png'))]
{code}
...the generated Elastic query (for example [^elasticQuery.json]) does not
seem to include the restriction on path (which would look something like [1]).
As such the Elastic query returns results from all over the nodestore, which
then get filtered out in Oak - see [2] - making the overall query extremely
slow.
I believe this is a result of changes to this class -
https://github.com/apache/jackrabbit-oak/blob/30ebc384a5ba2a2955cd31006c6c1454e8238ccd/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/query/ElasticRequestHandler.java#L258-L260
[1]
{code}
{"bool":{"filter":[{"term":{":ancestors":{"value":"/content/dam/folder1/subFolder1"}}}
{code}
[2]
{code}
20.11.2025 11:51:38.763 *TRACE* [elasticsearch-rest-client-0-thread-6]
org.apache.jackrabbit.oak.plugins.index.elastic.query.async.ElasticResultRowAsyncIterator
Path /content/dam/anotherfolder/testasset.jpg not included because of
hierarchy inclusion rules
{code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)