How to filter by multiple fields

I’m using the MetaMagik plugin to define custom fields in my tasks (Reviewer and Owner). However, I’m unable to create a filter that gathers all of the tasks that a user is responsible for - ones that they are the Assignee on, as well as the Reviewer (the custom field).

For instance, I can get all of the tasks that the user is the Assignee of with:

status:open Assignee:<USER>

However, if I try to include also the fields which the user is marked as the custom field Reviewer, I am not able to.

Is there some filter that I can use where either the Assignee field is <USER> OR the Reviewer field is <USER>?

EDIT:

FWIW I found the following Closed Github Issues:


1 Like

No OR operators, in general. But you can create custom filters, so it is possible, but will need to remain specific.

I believe the metamagik filters I included are chainable, I’ll double check next chance I get. And if I get a moment, I’ll see if I can make a filter to solve your specific need. If I happen to not get to it soon enough for you, take a look at:

For examples.

I actually looked into this a bit more, I could write you a filter, that would be specific to your need, but it would pretty much only be useful for you and in your exact methodology. However, after digging further into the LexerBuilder than I have ever looked I discovered, there actually is an OR Criteria. I’m not 100% sure how to exploit this, or if I even could, but I have some thoughts, which would be the better way to approach it…so that everyone can benefit. I just need to get some time to think about it and experiment.

You can see the OR criteria in action by simply using a filter more than once, i.e. assignee:name1 assignee:name2, but changing the filter brings it out of the OR loop, which becomes an AND…so basically assignee:name1 assignee:name2 metakey:owner metaval:name is Assignee name1 OR Assignee name2 AND Metakey owner AND Metaval name.

Pretty sure the best way to utilize the OrCriteria.php would be at the core, but not sure I would trust myself with that. As a filter/plugin, I could exploit it, by creating a filter that allows you to choose your search table, search column, and search value; but you would also need to specify the return and query in the task table…so it would get long and confusing…and to get what you want, it would look like, orfilter:users+name+searchname+id+owner_id orfilter:task_has_metadata+name+searchfield+task_id+id orfilter:task_has_metadata+value+searchvalue+task_id+id

And boy, does that look confusing…but since they would all be through the same filter, they would have the OR criteria…and it would find Assignees with the Name searchname OR Tasks with the Custom Field searchfield OR Tasks with the Custom Field Value searchvalue…which now that I think about it, is NOT what you want!!! see even I am confused…it would look like this then…

orfilter:users+name+searchname+id+owner_id metakey:searchfield orfilter:task_has_metadata+value+searchvalue+task_id+id

and now it would find Assignees with the Name searchname OR Tasks with the Custom Field Value searchvalue AND Tasks with the Custom Field searchfield.

This is all good in theory, but pretty sure the +'s would get stripped out…so, I’d have to figure out some serperators…

I’ll think about this some more…

I appreciate the amount of thought put into this. I don’t think it’s beneficial for either of us to work towards a workaround like this. I’m sure a well-implemented OR functionality can be elegantly introduced sooner or later.

FWIW, if Frederick Guillot could give us a brain dump of what he envisions it could look like, I’d be happier knowing that information is out there. Especially considering all that we have to go on right now is:

The OR operator is not yet supported.

1 Like

It seems like it’s just:

  1. beginOr()
  2. Raw query 1
  3. Raw query 2
  4. closeOr()

(see https://github.com/kanboard/kanboard/blob/master/app/Filter/TaskAssigneeFilter.php#L68-L71 for a reference)

It’s almost like any plugin would have to intercept and pre-process any query and split it up based on OR keywords. Of course, there should also be the additional option to parse parens in order to logically separate a self-contained OR statement.

i wasn’t referring to beginOr()…closeOr(), that works fine and you could utilize that for your own custom filter.

I was referring to: https://github.com/kanboard/kanboard/blob/master/app/Core/Filter/OrCriteria.php

which is being utilized in the LexerBuilder, here:

This is basically saying, if there are more than one value for a filter, use OR criterias, else, it’s an AND.

Yup, OR is already implicitly present, as far as I can tell. However, the lack of AND and NOT (or “-”) search filter operators in the main board view is one of the big showstopper personal productivity issues I have with kanboard (other than performance problems and Kanboard misinterpreting drag & drops as clicks on Firefox), without them it’s impossible to drill down tasks when you have a big backlog (for a “blogging pipeline” board, for example).

Various issues were reported there (and here) and there in the past, but those got closed in favor of the forum, considered feature requests rather than bugs.

The documentation at https://docs.kanboard.org/en/latest/user_guide/search.html hints that you can have a parameter multiple times, for example:

Multiple assignee lookup: assignee:user1 assignee:"John Doe"

…but from what I’ve seen when using this with tag:foo tag:bar, this behaves as an OR search, rather than an AND, as I get results that have either one of those tags. I also tried these variants, which don’t work:

tag:foo AND tag:bar
tag:foo NOT tag:bar
tag:foo -tag:bar
tag:foo+bar
tag:foo,bar

It would be so nice if they did, as I’d like to be able to search for, say, things tagged with “blog” that are not tagged with “technology”.

I wish there was a way to crowdfund some of kanboard’s features or bugfixes like these…

I cant remember if this one is an AND or OR

give it a try tho.

Oh joy! Your plugin actually allows queries such as tags:blog,tech to work as a “blog AND tech” search, that’s great! I hadn’t realized your plugin implemented that feature. But then it begs the question, why does that need to be a plugin, shouldn’t at least that syntax part be in the core of kanboard itself?

If I may suggest, maybe you could use “,” vs “+” to differentiate between OR and AND (so, using + for AND instead of “,”)? Or maybe the other way around: keeping “,” for AND but using “/” for OR if people want it.

The biggest remaining missing feature for me would be the “NOT” (or “-”) operator right before a string (or parameter) to be able to exclude things. Would your plugin be able to do that somehow, or that’s too core-y?

its a plugin, because it’s “MY” filter pack :wink: And I have shared it with everyone. And I don’t usually add to Core. I don’t trust myself.

edit: yes, there is a not equal to in picodb.