# Search itens by term

**URL:** <https://discourse.getcockpit.com/t/search-itens-by-term/70>\
**Category:** Support\
**Created:** [May 28, 2018, 6:31pm UTC](https://discourse.getcockpit.com/t/search-itens-by-term/70 "2018-05-28T18:31:48Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![jfzz](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/jfzz/32/360_2.png) [@jfzz](https://discourse.getcockpit.com/u/jfzz)\
**Post date:** [May 28, 2018, 6:31pm UTC](https://discourse.getcockpit.com/t/search-itens-by-term/70/1 "2018-05-28T18:31:48Z")

</div>

Hello.

I’m newbie and need a little help. How can I use API to search an iten by term? Eg.

/api/collections/get/products

I have products with name field. Is there any to search products that name=Iphone?

---

<div class="post-metadata">

**Author:** ![artur](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/artur/32/4_2.png) [@artur](https://discourse.getcockpit.com/u/artur)\
**Post date:** [May 28, 2018, 7:03pm UTC](https://discourse.getcockpit.com/t/search-itens-by-term/70/2 "2018-05-28T19:03:34Z")

</div>

Hi,

you can provide a filter parameter. e.g:

```auto
/api/collections/get/products?filter[name]=Iphone

```

For more information: [https://getcockpit.com/documentation/api/collections](https://getcockpit.com/documentation/api/collections)

Greets  
Artur

---

<div class="post-metadata">

**Author:** ![jfzz](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/jfzz/32/360_2.png) [@jfzz](https://discourse.getcockpit.com/u/jfzz)\
**Post date:** [May 28, 2018, 8:41pm UTC](https://discourse.getcockpit.com/t/search-itens-by-term/70/3 "2018-05-28T20:41:48Z")

</div>

Thank you for help me!

Works fine, but doens’t work if I search by iphone. Is there any way to work with lowercase with the same result?

---

<div class="post-metadata">

**Author:** ![artur](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/artur/32/4_2.png) [@artur](https://discourse.getcockpit.com/u/artur)\
**Post date:** [May 28, 2018, 8:53pm UTC](https://discourse.getcockpit.com/t/search-itens-by-term/70/4 "2018-05-28T20:53:30Z")

</div>

`/api/collections/get/products?filter[name][$regex]=iphone`

---

<div class="post-metadata">

**Author:** ![jb-storms-media](https://avatars.discourse-cdn.com/v4/letter/j/f4b2a3/32.png) [@jb-storms-media](https://discourse.getcockpit.com/u/jb-storms-media)\
**Post date:** [July 18, 2018, 9:21am UTC](https://discourse.getcockpit.com/t/search-itens-by-term/70/5 "2018-07-18T09:21:42Z")

</div>

how do you filter by multiple fileds? for example name=iphone and published=1 ?

\*edit

never mind; found out my self: ?filter[name]=iphone&filter[published]=1

---

<div class="post-metadata">

**Author:** ![unenouvelleville](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/unenouvelleville/32/83_2.png) [@unenouvelleville](https://discourse.getcockpit.com/u/unenouvelleville)\
**Post date:** [September 2, 2018, 6:56pm UTC](https://discourse.getcockpit.com/t/search-itens-by-term/70/6 "2018-09-02T18:56:46Z")

</div>

Hi,

Do you think it is possible to find differents terms at same time?  
/api/collections/get/products?filter[name]= **Iphone** &filter[name]= **Samsung**

Thank you 🙂

---

<div class="post-metadata">

**Author:** ![artur](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/artur/32/4_2.png) [@artur](https://discourse.getcockpit.com/u/artur)\
**Post date:** [September 2, 2018, 7:38pm UTC](https://discourse.getcockpit.com/t/search-itens-by-term/70/7 "2018-09-02T19:38:47Z")

</div>

the query should look like this (requesting as application/json)

```auto
{
  filter {
    $and: [
      {name: 'Iphone'},
      {name: 'Samsung'}
    ]
  }
}

```

Doing a GET request, this should look like this (not tested):

```auto
/api/collections/get/products?filter[$and][][name]=Iphone&filter[$and][][name]=Samsung

```

---

<div class="post-metadata">

**Author:** ![unenouvelleville](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/unenouvelleville/32/83_2.png) [@unenouvelleville](https://discourse.getcockpit.com/u/unenouvelleville)\
**Post date:** [September 2, 2018, 7:51pm UTC](https://discourse.getcockpit.com/t/search-itens-by-term/70/8 "2018-09-02T19:51:55Z")

</div>

> [@artur](#):
>
> ?filter[$and][name]=Iphone&filter[$and][name]=Samsung

Hey Artur,

When you request as app/json, it’s working well!  
But i’m more interested in GET request, and your request doesn’t work.

---

<div class="post-metadata">

**Author:** ![artur](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/artur/32/4_2.png) [@artur](https://discourse.getcockpit.com/u/artur)\
**Post date:** [September 2, 2018, 7:56pm UTC](https://discourse.getcockpit.com/t/search-itens-by-term/70/9 "2018-09-02T19:56:28Z")

</div>

> [@unenouvelleville](#):
>
> But i’m more interested in GET request, and your request doesn’t work.

can’t test it right now, but try this:

```auto
/api/collections/get/products?filter[$and][0][name]=Iphone&filter[$and][1][name]=Samsung

```

---

<div class="post-metadata">

**Author:** ![unenouvelleville](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/unenouvelleville/32/83_2.png) [@unenouvelleville](https://discourse.getcockpit.com/u/unenouvelleville)\
**Post date:** [September 2, 2018, 8:06pm UTC](https://discourse.getcockpit.com/t/search-itens-by-term/70/10 "2018-09-02T20:06:47Z")

</div>

@artur

Mmmmm, i think i am a bit tired! We can’t use AND, but **OR**!

> /api/collections/get/products?filter[$or][0][name]=iPhone&filter[$or][1][name]=Samsung

Thank you for your precious help!

---

<div class="post-metadata">

**Author:** ![easysoft-mobility](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/easysoft-mobility/32/500_2.png) [@easysoft-mobility](https://discourse.getcockpit.com/u/easysoft-mobility)\
**Post date:** [February 28, 2020, 1:37pm UTC](https://discourse.getcockpit.com/t/search-itens-by-term/70/11 "2020-02-28T13:37:26Z")

</div>

> [@artur](#):
>
> [$and][0][name]

Hello !

How can we filter collections based on words contained in a field. (As the ‘LIKE’ condition in sql/sqlite). I’m using sqlite in my config but filtering work only when all the field’s value is filled in for the request. I mean, I’ve to query with all the content of the title of a post before it can show in response (from API).

Thanks !

---

<div class="post-metadata">

**Author:** ![easysoft-mobility](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/easysoft-mobility/32/500_2.png) [@easysoft-mobility](https://discourse.getcockpit.com/u/easysoft-mobility)\
**Post date:** [February 28, 2020, 3:48pm UTC](https://discourse.getcockpit.com/t/search-itens-by-term/70/12 "2020-02-28T15:48:44Z")

</div>

Issue resolved !

Explanation here:

In my collection, I need to get all items that have a specific word in they title.  
Using Postman here is how a did it:

1- Set request url to this: https://your\_website/api/collections/get/YOUR\_COLLECTION?token=YOUR\_TOKEN (request type must be GET or POST)  
2- Set request body to “raw” with type “JSON” and content like below:  
{  
“filter”: {  
“YOUR\_COLLECTION\_FIELD\_TO\_QUERY\_ON”: {"$regex": “THE\_WORD\_YOU\_ARE\_SEARCHING\_FOR”}  
}  
}

---

<div class="post-metadata">

**Author:** ![nirmal.patel](https://avatars.discourse-cdn.com/v4/letter/n/bb73d2/32.png) [@nirmal.patel](https://discourse.getcockpit.com/u/nirmal.patel)\
**Post date:** [April 23, 2020, 11:11am UTC](https://discourse.getcockpit.com/t/search-itens-by-term/70/13 "2020-04-23T11:11:49Z")

</div>

Thank you all for helping with the solution.  
To search entries in collection we require collection name (like products, as mentioned in your comment.)  
However, I am looking for global search.  
At the top we are having `search for anything`. can I use this search input to search any entries in any collection.

For example,  
I am having following collections with entries.

Collection Name :: **POST**

- Post1
- Post2

Collection Name :: **Gallery**

- thumbnail1
- logo

So can I search here with entries (like thumbnail1 or post1) directly irrespective of collection name?

---

<div class="post-metadata">

**Author:** ![DeHekOnline](https://avatars.discourse-cdn.com/v4/letter/d/97f17d/32.png) [@DeHekOnline](https://discourse.getcockpit.com/u/DeHekOnline)\
**Post date:** [November 9, 2020, 7:32am UTC](https://discourse.getcockpit.com/t/search-itens-by-term/70/14 "2020-11-09T07:32:10Z")

</div>

Did you find a way to search for a field in all collections?

---

<div class="post-metadata">

**Author:** ![raffaelj](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/raffaelj/32/331_2.png) [@raffaelj](https://discourse.getcockpit.com/u/raffaelj)\
**Post date:** [November 12, 2020, 8:50am UTC](https://discourse.getcockpit.com/t/search-itens-by-term/70/15 "2020-11-12T08:50:38Z")

</div>

You can’t search in all collections by default, but you can write a custom api endpoint to do that job. In this thread are two possible solutions:

> [@Querying multiple collections is giving - Collection not found](https://discourse.getcockpit.com/t/querying-multiple-collections-is-giving-collection-not-found/1631):
>
> I am trying to query multiple collections as shown - /api/collections/get/(authors|posts) But i keep getting the error like - { "error": "Collection not found" } Can anyone help me where i am going wrong? The individual APIs work correctly
