# API - Search for items containing text

**URL:** <https://discourse.getcockpit.com/t/api-search-for-items-containing-text/2065>\
**Category:** Uncategorized\
**Created:** [September 6, 2021, 8:09pm UTC](https://discourse.getcockpit.com/t/api-search-for-items-containing-text/2065 "2021-09-06T20:09:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![linhous](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/linhous/32/900_2.png) [@linhous](https://discourse.getcockpit.com/u/linhous)\
**Post date:** [September 6, 2021, 8:09pm UTC](https://discourse.getcockpit.com/t/api-search-for-items-containing-text/2065/1 "2021-09-06T20:09:14Z")

</div>

hello again guys,

I would like to know if there is a way for me to do a search in a given collection, but not using an EXACT term, but that it CONTAINS a certain term in some part of the text.

Example:  
POST: api/collections/get/articles  
Body: `{ "limit": 10, "filter": { "content" : "%phone%" }, "sort": {"_created":-1} }`

Note that in this example I use ‘%’ as I would in a database query using ‘LIKE’.

And then, in a given entry that has a CONTENT field filled in with ‘My beautiful phone’ it would be one of the entries I would list, as it has the text ‘phone’ inside the CONTENT field.

Does Cockpit provide any ‘native’ features for this?  
Thank you very much to everyone in advance!

---

<div class="post-metadata">

**Author:** ![abernh](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/abernh/32/859_2.png) [@abernh](https://discourse.getcockpit.com/u/abernh)\
**Post date:** [September 7, 2021, 8:07am UTC](https://discourse.getcockpit.com/t/api-search-for-items-containing-text/2065/2 "2021-09-07T08:07:55Z")

</div>

Yes, there is such a thing, the `$regex` filter.

POST:  
`api/collections/get/articles`  
Body:

```auto
{     
  "limit": 10,     
  "filter": {   
    "content": {      
      "$regex" : "(phone|tablet)" // a valid PHP regular expression without slashes
    }
  },     
  "sort": { 
    "_created" : -1
  } 
}

```

rel [Search itens by term - #4 by artur](https://discourse.getcockpit.com/t/search-itens-by-term/70/4)

---

<div class="post-metadata">

**Author:** ![linhous](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/linhous/32/900_2.png) [@linhous](https://discourse.getcockpit.com/u/linhous)\
**Post date:** [September 7, 2021, 2:55pm UTC](https://discourse.getcockpit.com/t/api-search-for-items-containing-text/2065/3 "2021-09-07T14:55:43Z")

</div>

Dude, thanks a lot!

I had viewed this topic but hadn’t seen it that way, I thought it was something else. Thank you very much for the explanation, it was very specific!
