# How to filter by multiple fields

**URL:** <https://kanboard.discourse.group/t/how-to-filter-by-multiple-fields/249>\
**Category:** Open Discussions\
**Created:** [March 8, 2019, 5:23am UTC](https://kanboard.discourse.group/t/how-to-filter-by-multiple-fields/249 "2019-03-08T05:23:35Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![smacz42](https://yyz2.discourse-cdn.com/free1/user_avatar/kanboard.discourse.group/smacz42/32/696_2.png) [@smacz42](https://kanboard.discourse.group/u/smacz42)\
**Post date:** [March 8, 2019, 5:23am UTC](https://kanboard.discourse.group/t/how-to-filter-by-multiple-fields/249/1 "2019-03-08T05:23:35Z")

</div>

I’m using the [MetaMagik](https://github.com/creecros/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:

```auto
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:

> <https://github.com/kanboard/kanboard/issues/2728>

  

> <https://github.com/kanboard/kanboard/issues/2519>

---

<div class="post-metadata">

**Author:** ![creecros](https://yyz2.discourse-cdn.com/free1/user_avatar/kanboard.discourse.group/creecros/32/156_2.png) [@creecros](https://kanboard.discourse.group/u/creecros)\
**Post date:** [March 8, 2019, 11:56am UTC](https://kanboard.discourse.group/t/how-to-filter-by-multiple-fields/249/2 "2019-03-08T11:56:52Z")

</div>

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:

> **[creecros/Creecros\_Filter\_Pack](https://github.com/creecros/Creecros_Filter_Pack)**
>
> Kanboard filters. Contribute to creecros/Creecros\_Filter\_Pack development by creating an account on GitHub.

For examples.

---

<div class="post-metadata">

**Author:** ![creecros](https://yyz2.discourse-cdn.com/free1/user_avatar/kanboard.discourse.group/creecros/32/156_2.png) [@creecros](https://kanboard.discourse.group/u/creecros)\
**Post date:** [March 8, 2019, 8:31pm UTC](https://kanboard.discourse.group/t/how-to-filter-by-multiple-fields/249/3 "2019-03-08T20:31:36Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![smacz42](https://yyz2.discourse-cdn.com/free1/user_avatar/kanboard.discourse.group/smacz42/32/696_2.png) [@smacz42](https://kanboard.discourse.group/u/smacz42)\
**Post date:** [March 15, 2019, 1:28am UTC](https://kanboard.discourse.group/t/how-to-filter-by-multiple-fields/249/4 "2019-03-15T01:28:10Z")

</div>

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.](https://github.com/kanboard/kanboard/issues/2519#issuecomment-235743528)

---

<div class="post-metadata">

**Author:** ![smacz42](https://yyz2.discourse-cdn.com/free1/user_avatar/kanboard.discourse.group/smacz42/32/696_2.png) [@smacz42](https://kanboard.discourse.group/u/smacz42)\
**Post date:** [March 15, 2019, 2:01am UTC](https://kanboard.discourse.group/t/how-to-filter-by-multiple-fields/249/5 "2019-03-15T02:01:59Z")

</div>

> [@creecros](#):
>
> Pretty sure the best way to utilize the OrCriteria.php would be at the core

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](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.

---

<div class="post-metadata">

**Author:** ![creecros](https://yyz2.discourse-cdn.com/free1/user_avatar/kanboard.discourse.group/creecros/32/156_2.png) [@creecros](https://kanboard.discourse.group/u/creecros)\
**Post date:** [March 15, 2019, 2:13am UTC](https://kanboard.discourse.group/t/how-to-filter-by-multiple-fields/249/6 "2019-03-15T02:13:20Z")

</div>

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](https://github.com/kanboard/kanboard/blob/master/app/Core/Filter/OrCriteria.php)

which is being utilized in the LexerBuilder, here:

> <https://github.com/kanboard/kanboard/blob/7bb1f927e8d2b68f6f47d8842af5ac9e8e7f9cef/app/Core/Filter/LexerBuilder.php#L127-L139>

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

---

<div class="post-metadata">

**Author:** ![nekohayo](https://yyz2.discourse-cdn.com/free1/user_avatar/kanboard.discourse.group/nekohayo/32/315_2.png) [@nekohayo](https://kanboard.discourse.group/u/nekohayo)\
**Post date:** [February 5, 2021, 1:33am UTC](https://kanboard.discourse.group/t/how-to-filter-by-multiple-fields/249/7 "2021-02-05T01:33:18Z")

</div>

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](https://kanboard.discourse.group/t/some-of-the-biggest-performance-issues-are-in-the-board-view-not-the-sqlite-database-backend/762) and Kanboard [misinterpreting drag & drops as clicks on Firefox](https://github.com/kanboard/kanboard/issues/4412)), 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](https://github.com/kanboard/kanboard/issues/3768) (and [here](https://kanboard.discourse.group/t/expansive-search/143)) and [there](https://github.com/kanboard/kanboard/issues/1472) 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](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…

---

<div class="post-metadata">

**Author:** ![creecros](https://yyz2.discourse-cdn.com/free1/user_avatar/kanboard.discourse.group/creecros/32/156_2.png) [@creecros](https://kanboard.discourse.group/u/creecros)\
**Post date:** [February 5, 2021, 2:50am UTC](https://kanboard.discourse.group/t/how-to-filter-by-multiple-fields/249/8 "2021-02-05T02:50:29Z")

</div>

I cant remember if this one is an AND or OR

give it a try tho.

> **[creecros/Creecros\_Filter\_Pack - 🔖 Tags](https://github.com/creecros/Creecros_Filter_Pack#bookmark-tags)**
>
> Kanboard filters. Contribute to creecros/Creecros\_Filter\_Pack development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![nekohayo](https://yyz2.discourse-cdn.com/free1/user_avatar/kanboard.discourse.group/nekohayo/32/315_2.png) [@nekohayo](https://kanboard.discourse.group/u/nekohayo)\
**Post date:** [February 5, 2021, 3:30am UTC](https://kanboard.discourse.group/t/how-to-filter-by-multiple-fields/249/9 "2021-02-05T03:30:21Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![creecros](https://yyz2.discourse-cdn.com/free1/user_avatar/kanboard.discourse.group/creecros/32/156_2.png) [@creecros](https://kanboard.discourse.group/u/creecros)\
**Post date:** [February 5, 2021, 3:41am UTC](https://kanboard.discourse.group/t/how-to-filter-by-multiple-fields/249/10 "2021-02-05T03:41:39Z")

</div>

its a plugin, because it’s “MY” filter pack 😉 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.
