orgzly-android icon indicating copy to clipboard operation
orgzly-android copied to clipboard

Search expression to match only "leaf" notes

Open bobrippling opened this issue 1 year ago • 4 comments

  • [X] I have searched for existing issues that may be the same as or related to mine.

If I have notes such as:

* Shopping :shopping:
** Bread
** Veg
*** Carrots
*** Cabbage

Where I've grouped some items, I'd like to find all "leaf" items, and ignore the groups. In other words, items without children, so in this case, Bread, Carrots and Cabbage.

Would a change to add a leaf search expression be accepted? If so I can create a PR. It would be something like:

t.shopping leaf or t.shopping hierarchy.leaf / t.shopping h.leaf if we wanted to avoid the "leaf" bareword being by itself

bobrippling avatar Sep 22 '24 14:09 bobrippling

I'm making progress on implementing the leaf note search feature. A summary of my work up to date.

  • I've introduced a recursive CTE to fetch child elements of live data notes after applying other filters.
  • Added a new boolean property searchLeafNotes to the Options data class. This will act as a trigger for the new search option in DataRepository.

Here's how it works (using "h.leaf" in the search bar):

  1. For tags: Get all "t.shopping" IDs, then fetch all leaf notes for "t.shopping h.leaf"
  2. For title/content: Get list item IDs with "shopping" in title or content, then retrieve all leaf children of those IDs

Summary of fix list:

  • Tag leaf note searches are working as expected, which is good
  • Title/content searches aren't quite there yet (still returning non-leaf results)
  • During debugging, I confirmed the first query (getting filtered note IDs) works in both cases

The raw SQL runs fine in SQLite Workbench, but I need to refine the Android methods to ensure it works for most, if not all, search filters.

I'll submit a PR once all my tests are passing.

TheAttentionSeeker5050 avatar Mar 17 '25 14:03 TheAttentionSeeker5050

Oh great stuff, thank you! That was a quick turn around to a PR too, thanks for summarising here. I've a few questions but I'll pop them on the PR

bobrippling avatar Mar 18 '25 08:03 bobrippling

@bobrippling @TheAttentionSeeker5050 This project was abandoned in 2022. There is a fork here: https://github.com/orgzly-revived/orgzly-android-revived

amberin avatar May 04 '25 20:05 amberin

Ah great - thanks @amberin!

bobrippling avatar May 08 '25 07:05 bobrippling