Search expression to match only "leaf" notes
- [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
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
searchLeafNotesto 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):
- For tags: Get all "t.shopping" IDs, then fetch all leaf notes for "t.shopping h.leaf"
- 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.
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 @TheAttentionSeeker5050 This project was abandoned in 2022. There is a fork here: https://github.com/orgzly-revived/orgzly-android-revived
Ah great - thanks @amberin!