Skip to content

Conversation

@TheAttentionSeeker5050
Copy link

Implementation for feature: Search expression to match only "leaf" notes #1059

Using two queries to get only the leaf notes when the search input includes h.leaf (leaf hierarchy).

The first SQL query works as usual. If it's a leaf search, it's saved in the Options property called searchLeafNotes.

Inside selectNotesFromQueryLiveData, once this property is checked and we get the NoteView LiveData array based on other criteria, the process maps them into a list of Long note IDs. Then, another SQL query runs to recursively find child notes from the original search. Finally, it filters out any notes that are parents of another note in the results, leaving only the leaf notes.

Tested with the following inputs:

  • t.tag2 h.leaf
  • fold h.leaf
  • i.todo h.leaf

Copy link

@bobrippling bobrippling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! I wonder - what will happen when the leaf query isn't at the top level, for example: t.work or (b.gifts and h.leaf) ?

if (days > 0) options.copy(agendaDays = days) else null
},
OptionMatch("""^(\.)?h\.(.+)""") { match, options ->
if (match.groupValues[2].lowercase() == HyerarchyType.LEAF.toString().lowercase())

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps the file that defines HyerarchyType is missing?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will check this out Bob.

Copy link
Author

@TheAttentionSeeker5050 TheAttentionSeeker5050 Mar 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, the HierarchyType enum class was not added into the Git commit. As it was part of a previous iteration to solve this problem.

I am working on it

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added HierarchyType and fixed its name typo (before, it was spelled incorrectly as HyerarchyType)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks! I guess the filename just needs the typo change too?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed the typo

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Youre right the file name sorry I will fix it ASAP

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries, thanks!

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File renamed

@TheAttentionSeeker5050
Copy link
Author

TheAttentionSeeker5050 commented Mar 18, 2025

t.work

Can you please explain this more in depth? I only set up the leaf option as of this date on hierarchy type. So the query with this option on will make all the query then perform the search leaf notes and filter out the parents. The order of the input doesn't affect the result as far as I am aware. Example: fold h.leaf, fold and h.leaf, h.leaf fold, fold (h.leaf), (fold) h.leaf , (fold h.leaf) all return the same result.

Edit: The leaf notes means that it will only return the very end children of the search query, all the parents and intermediate children do not make part of the end result. They are filtered out.

@bobrippling
Copy link

bobrippling commented Mar 18, 2025

t.work

Can you please explain this more in depth? I only set up the leaf option as of this date on hierarchy type. So the query with this option on will make all the query then perform the search leaf notes and filter out the parents. The order of the input doesn't affect the result as far as I am aware. Example: fold h.leaf, fold and h.leaf, h.leaf fold, fold (h.leaf), (fold) h.leaf , (fold h.leaf) all return the same result.

Sure - what I mean is that the leaf part is more a condition than an option, so we want it to behave like tag, or state for example.

This would mean we can then look for notes which are either:

  • tagged with "work" (while not necessarily a leaf note)
  • leaf-notes which are tagged with "gift"

(in the above example, t.work or (b.gifts and h.leaf)), rather than it being an all-or-nothing option, if you see what I mean?

@TheAttentionSeeker5050
Copy link
Author

t.work

Can you please explain this more in depth? I only set up the leaf option as of this date on hierarchy type. So the query with this option on will make all the query then perform the search leaf notes and filter out the parents. The order of the input doesn't affect the result as far as I am aware. Example: fold h.leaf, fold and h.leaf, h.leaf fold, fold (h.leaf), (fold) h.leaf , (fold h.leaf) all return the same result.

Sure - what I mean is that the leaf part is more a condition than an option, so we want it to behave like tag, or state for example.

This would mean we can then look for notes which are either:

  • tagged with "work" (while not necessarily a leaf note)
  • leaf-notes which are tagged with "gift"

(in the above example, t.work or (b.gifts and h.leaf)), rather than it being an all-or-nothing option, if you see what I mean?

Now I understand. I will have a look at this case.

@amberin
Copy link
Contributor

amberin commented Nov 29, 2025

@TheAttentionSeeker5050 @bobrippling Hi guys, this project has been abandoned for three years now. There is an active fork here: https://github.com/orgzly-revived/orgzly-android-revived

Feel free to open a PR!

@bobrippling
Copy link

Thanks @amberin! For reference / anyone following, the corresponding orgzly-revived issue is here: orgzly-revived/orgzly-android-revived#653

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants