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?
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?
Hi,
you can provide a filter parameter. e.g:
/api/collections/get/products?filter[name]=Iphone
For more information: https://getcockpit.com/documentation/api/collections
Greets
Artur
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?
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
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
the query should look like this (requesting as application/json)
{
filter {
$and: [
{name: 'Iphone'},
{name: 'Samsung'}
]
}
}
Doing a GET request, this should look like this (not tested):
/api/collections/get/products?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.
can’t test it right now, but try this:
/api/collections/get/products?filter[$and][0][name]=Iphone&filter[$and][1][name]=Samsung
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!
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 !
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”}
}
}
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
Collection Name :: Gallery
So can I search here with entries (like thumbnail1 or post1) directly irrespective of collection name?
Did you find a way to search for a field in all collections?
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: