-
Bug
-
Resolution: Unresolved
-
Neutral
-
None
-
2.0.3
-
None
-
None
The query used in searchfn searches on the subnodes of the provided node. This skips the data the on the passed in path leading to a confusing developer experience.
For example, the travel-demo search results component provides /travel in the ftl. Turning on the debug for SearchTemplatingFunctions we find:
DEBUG info.magnolia.templating.functions.SearchTemplatingFunctions 22.08.2023 08:35:52 -- Executing query against workspace [website] with statement [SELECT rep:excerpt() from mgnl:page WHERE jcr:path like '/travel/%' AND contains(., 'Richard') ORDER BY jcr:score DESC] and limit 2147483647 and offset 0... DEBUG info.magnolia.templating.functions.SearchTemplatingFunctions 22.08.2023 08:35:52 -- Query execution took 2 ms DEBUG info.magnolia.templating.functions.SearchTemplatingFunctions 22.08.2023 08:35:52 -- Executing query against workspace [tours] with statement [SELECT rep:excerpt() from mgnl:content WHERE jcr:path like '/magnolia-travels/%' AND contains(., 'Richard') ORDER BY jcr:score DESC] and limit 2147483647 and offset 0... DEBUG info.magnolia.templating.functions.SearchTemplatingFunctions 22.08.2023 08:35:52 -- Query execution took 2 ms
Now we can see the first query of the website workspace /travel/% which skips the node travel entirely.
Reproduce
- Open the travel demo home page for editing.
- Open the page properties dialog.
- Enter some text on the abstract field that can only be found on that page. For example, "Richard".
- Pop the demo site out into a new tab for viewing and perform a search on the term.
- Observe the page isn't found in the results.
Expected
The search result should also include the page (path) which was passed in: /travel
Actual
Only the subpages of the passed in path are searched.
Notes
From what I have seen the only option is to perform two queries and combine the results.
SELECT rep:excerpt() from mgnl:page WHERE jcr:path like '/travel/%' AND contains(., 'Richard') ORDER BY jcr:score DESC SELECT rep:excerpt() from mgnl:page WHERE jcr:path like '/travel' AND contains(., 'Richard') ORDER BY jcr:score DESC
- relates to
-
MGNLDEMO-420 searchfn.searchPage() doesn't return results for home (top level page in the website)
- Open
-
MTE-91 searchfn is not searching in parent page
- Closed