[MTE-151] searchfn doesn't search the configured node Created: 22/Aug/23  Updated: 29/Nov/23

Status: Open
Project: Magnolia Templating Essentials
Component/s: None
Affects Version/s: 2.0.3
Fix Version/s: None

Type: Bug Priority: Neutral
Reporter: Richard Gange Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Relates
relates to MGNLDEMO-420 searchfn.searchPage() doesn't return ... Open
relates to MTE-91 searchfn is not searching in parent page Closed
relation
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Epic Link: Support
Team: DeveloperX

 Description   

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

Generated at Mon Feb 12 07:42:00 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.