# How to allow for multiple constraints in a search?

**URL:** <https://forum.bubble.io/t/how-to-allow-for-multiple-constraints-in-a-search/155960>\
**Category:** Database\
**Created:** [June 16, 2021, 7:22pm UTC](https://forum.bubble.io/t/how-to-allow-for-multiple-constraints-in-a-search/155960 "2021-06-16T19:22:02Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![wknepp](https://avatars.discourse-cdn.com/v4/letter/w/90db22/32.png) [@wknepp](https://forum.bubble.io/u/wknepp)\
**Post date:** [June 16, 2021, 7:22pm UTC](https://forum.bubble.io/t/how-to-allow-for-multiple-constraints-in-a-search/155960/1 "2021-06-16T19:22:02Z")

</div>

![Screen Shot 2021-06-16 at 2.57.18 PM](https://us1.discourse-cdn.com/bubble/original/3X/9/7/97e42f0bfce9eedf330e722d743b1fcdba14d15e.png)  
I’m trying to have 2 possibilities when searching for something in a list. I was wondering if anyone knew how I could do this? I would like to have either of the black boxes be true for it to show up in the search. If anyone is confused on what I’m asking please let me know!

---

<div class="post-metadata">

**Author:** ![Jici](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/jici/32/30722_2.png) [@Jici](https://forum.bubble.io/u/Jici)\
**Post date:** [June 16, 2021, 8:14pm UTC](https://forum.bubble.io/t/how-to-allow-for-multiple-constraints-in-a-search/155960/2 "2021-06-16T20:14:38Z")

</div>

You will need to use :merge with and :unique item  
So a first search will look for Sender = Current user and Receive = Curren’s user observings user :merge with do a search for… Sender = Current user’s observing user’s and receiver = current user : unique elements

However, you can consider to have a field that have both information (involved, list of user) and you search for the list to contain Current user AND Current user’s observing user. It will reduce the number of search

---

<div class="post-metadata">

**Author:** ![wknepp](https://avatars.discourse-cdn.com/v4/letter/w/90db22/32.png) [@wknepp](https://forum.bubble.io/u/wknepp)\
**Post date:** [June 16, 2021, 8:17pm UTC](https://forum.bubble.io/t/how-to-allow-for-multiple-constraints-in-a-search/155960/3 "2021-06-16T20:17:46Z")

</div>

I used the first option and it worked great! Thank you so much!

---

<div class="post-metadata">

**Author:** ![wknepp](https://avatars.discourse-cdn.com/v4/letter/w/90db22/32.png) [@wknepp](https://forum.bubble.io/u/wknepp)\
**Post date:** [June 16, 2021, 8:25pm UTC](https://forum.bubble.io/t/how-to-allow-for-multiple-constraints-in-a-search/155960/4 "2021-06-16T20:25:42Z")

</div>

Wait there’s a problem. When I merge them they don’t retain their order that they were sent in. It puts one merged list after the other. In this image, test 2 should be the second message, not at the end.

 ![Screen Shot 2021-06-16 at 3.24.40 PM](https://us1.discourse-cdn.com/bubble/original/3X/1/5/15dcc4f33bdf5b89a3f5e9e77f9da51c5233528b.png)

---

<div class="post-metadata">

**Author:** ![Jici](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/jici/32/30722_2.png) [@Jici](https://forum.bubble.io/u/Jici)\
**Post date:** [June 16, 2021, 8:27pm UTC](https://forum.bubble.io/t/how-to-allow-for-multiple-constraints-in-a-search/155960/5 "2021-06-16T20:27:58Z")

</div>

use :sorted by  
And select the field you wan’t to use to sort the whole list. This need to be the last step

---

<div class="post-metadata">

**Author:** ![marksrunge](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/marksrunge/32/84554_2.png) [@marksrunge](https://forum.bubble.io/u/marksrunge)\
**Post date:** [June 16, 2021, 8:42pm UTC](https://forum.bubble.io/t/how-to-allow-for-multiple-constraints-in-a-search/155960/6 "2021-06-16T20:42:00Z")

</div>

Thanks Jici  
Your solution helps me as well 👍
