# Search api - combine "in" and "contains" predicates

**URL:** <https://community.shotgridsoftware.com/t/search-api-combine-in-and-contains-predicates/14502>\
**Category:** Pipeline Integrations\
**Created:** [January 19, 2022, 10:31am UTC](https://community.shotgridsoftware.com/t/search-api-combine-in-and-contains-predicates/14502 "2022-01-19T10:31:36Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mmoshev](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/mmoshev/32/476_2.png) [@mmoshev](https://community.shotgridsoftware.com/u/mmoshev)\
**Post date:** [January 19, 2022, 10:31am UTC](https://community.shotgridsoftware.com/t/search-api-combine-in-and-contains-predicates/14502/1 "2022-01-19T10:31:36Z")

</div>

Ran into an interesting problem today - I would like to search for partial matches of a list of items. This would be a combination of the predicates “in” and “contains”.

For instance `find_one("PublishedFile", [["created_by.HumanUser.login", "in", ["schwartz", "term"]]])`

I understand I can achieve this with compound filters like

```auto
{ "filter_operator": "any",
  "filters": [
    ["created_by.HumanUser.login", "contains", "schwartz"],
    ["created_by.HumanUser.login", "contains", "term"]]}

```

just wondering if there is a shortcut for this.

Any ideas?

---

<div class="post-metadata">

**Author:** ![davidma](https://avatars.discourse-cdn.com/v4/letter/d/e5b9ba/32.png) [@davidma](https://community.shotgridsoftware.com/u/davidma)\
**Post date:** [January 25, 2022, 9:11pm UTC](https://community.shotgridsoftware.com/t/search-api-combine-in-and-contains-predicates/14502/2 "2022-01-25T21:11:39Z")

</div>

As mentioned - I think the best way to handle this case is with the compound filters.

From my experience it’s best to limit the use of `contains` as much as possible due to inefficiencies of that operator.

First getting a list of `find("PublishedFile", filters, ["created_by.HumanUser.login"])`  
Then relying on your scripting language to perform the fuzzy logic on the return fields to identify the first item / sub-set matching your needs may help save SG from itself.

---

<div class="post-metadata">

**Author:** ![mmoshev](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/mmoshev/32/476_2.png) [@mmoshev](https://community.shotgridsoftware.com/u/mmoshev)\
**Post date:** [January 26, 2022, 7:38am UTC](https://community.shotgridsoftware.com/t/search-api-combine-in-and-contains-predicates/14502/3 "2022-01-26T07:38:51Z")

</div>

Hm, is this indeed the case? I would expect server-side filtering to be faster in general. You may be greatly limiting the amount of data that needs to flow.  
But then again, you cannot say these things without profiling them 🙂  
I’ll try to put together a test. This would also depend a lot on the data, so it would be nice to test out different data profiles.

---

<div class="post-metadata">

**Author:** ![PhilFranjo](https://avatars.discourse-cdn.com/v4/letter/p/97f17d/32.png) [@PhilFranjo](https://community.shotgridsoftware.com/u/PhilFranjo)\
**Post date:** [March 31, 2023, 4:09pm UTC](https://community.shotgridsoftware.com/t/search-api-combine-in-and-contains-predicates/14502/4 "2023-03-31T16:09:23Z")

</div>

Did you end up finding a good approach to this issue? Thinking about the same thing to lighten my query and avoid the “any” operator.

---

<div class="post-metadata">

**Author:** ![mmoshev](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/mmoshev/32/476_2.png) [@mmoshev](https://community.shotgridsoftware.com/u/mmoshev)\
**Post date:** [April 2, 2023, 2:36pm UTC](https://community.shotgridsoftware.com/t/search-api-combine-in-and-contains-predicates/14502/5 "2023-04-02T14:36:30Z")

</div>

Nope, using compound filters, and it works fine with a small utility function to generate them.
