Boolean operators when Searching

Hi there,

I’m trying to run a search query using:
@delegate and (@today union @due <[d] tomorrow)

But when I add the parenthesis the whole statement after the “and” goes red and it doesn’t work. What would be the correct expression to achieve this?

many thanks

That search is getting somewhat complex, if you haven’t yet you should check out the search documentation:

https://guide.taskpaper.com/reference/searches/

TaskPaper search has boolean operators and, or, not and set operators union, intersect , and except . They are used for two different things.

The boolean operators are used to create predicates for matching against individual items.

The set operators are for combining the results of different item paths. They work on sets of items.

Can you describe what items exactly you are trying to show in a bit more detail? That will help me construct a proper search.

1 Like

I want to get tasks that don’t have @delegated and that are due. With the tasks below I’d expect to get “Task 2” as a result:

  • Task 1 @due(2017-08-14) @delegated(Person)
  • Task 2 @due(2017-08-14)

Many thanks!

Ok, you could do that a few different ways I think. One way would be:

not @delegated and (@today or @due <=[d] today + 24h)

If all of your search logic can be done by testing the attributes of each item separately then combining with boolean operators works well.

On the other hand that search might not do what you want in this case:

- Task 1 @due(2017-08-14)
@delegated(Person)
	- Task 2 @due(2017-08-14) 
	- Task 3 @due(2017-08-14) 
	- Task 4 @due(2017-08-14) 

Here I’ve intended Task 2-4 under a @delegated(Person) item. In this setup I mean that all those tasks should be delegated to that person, but the first search that I suggested will still show all tasks. And we can’t solve this problem using boolean operators, because they are only useful for testing attributes on items individually… not in hierarchical context.

But this case can be solved like

@today or @due <=[d] today + 24h except @delegated///*

It says … find all items that are due… and then from those results remove all items that tagged delegated or descendants of an item tagged @delegated.

To really understand what’s going on please see that user guide link. It should help a lot I think.

1 Like

many thanks, that helps a lot!