# API search functionality

**URL:** <https://community.datagerry.com/t/api-search-functionality/382>\
**Category:** Community Support\
**Created:** [July 12, 2021, 8:14pm UTC](https://community.datagerry.com/t/api-search-functionality/382 "2021-07-12T20:14:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lostboi](https://avatars.discourse-cdn.com/v4/letter/l/e19adc/32.png) [@Lostboi](https://community.datagerry.com/u/Lostboi)\
**Post date:** [July 12, 2021, 8:14pm UTC](https://community.datagerry.com/t/api-search-functionality/382/1 "2021-07-12T20:14:05Z")

</div>

Dear DATAGERRY community,

As we can see from the API documentation, you need to address the so-called public\_id.  
Is there a way to get the corresponding public\_id for a “name” via the API?

Or is there perhaps a way to trigger a search via the API? Unfortunately we could not find anything in the API documentation.

All the best,  
Stephan

---

<div class="post-metadata">

**Author:** ![sergej.dumler](https://avatars.discourse-cdn.com/v4/letter/s/bb73d2/32.png) [@sergej.dumler](https://community.datagerry.com/u/sergej.dumler)\
**Post date:** [July 13, 2021, 8:40am UTC](https://community.datagerry.com/t/api-search-functionality/382/2 "2021-07-13T08:40:55Z")

</div>

Hello @Lostboi ,

in the attachment you will find a small example of searching for a type by name.

```auto
GET /rest/types/?
	sort='public_id'&
	order=1&
	page=1&
        limit=10&
	filter=[
		{"$addFields":
			{"public_id":
				{"$toString":"$public_id"}
			}
		},
		{"$match":
			{"$or":[
				{"public_id":
					{"$regex":"Example","$options":"ismx"}
				},
				{"name":
					{"$regex":"Example","$options":"ismx"}
				},
				{"author_id":
					{"$regex":"Example","$options":"ismx"}
				},
				{"editor_id":
					{"$regex":"Example","$options":"ismx"}
				},
				{"public_id":
					{"$elemMatch":
						{"value":
							{"$regex":"Example","$options":"ismx"}
						}
					}
				}
			]}
		}
	] HTTP/1.1

Host: localhost:4000
Content-Type: application/json
Authorization: Basic YWRtaW46YWRtaW4=
cache-control: no-cache
Postman-Token: 7fdc7e4f-176d-4fbd-a2c8-c0aa2c367a6b

```

The structure of our filter function via Rest is based on the structure of the [Aggregatino pipelines](https://docs.mongodb.com/manual/reference/operator/aggregation-pipeline/) ([Operator](https://docs.mongodb.com/manual/reference/operator/aggregation/))of the MongoDB library. With the Aggregatino pipelines you can map all search queries. No data is created or changed with the Aggregatino pipelines. They are only used for display.

With kind regards

---

<div class="post-metadata">

**Author:** ![adnan.smajic](https://dub1.discourse-cdn.com/flex013/user_avatar/community.datagerry.com/adnan.smajic/32/754_2.png) [@adnan.smajic](https://community.datagerry.com/u/adnan.smajic)\
**Post date:** [June 20, 2023, 10:45am UTC](https://community.datagerry.com/t/api-search-functionality/382/3 "2023-06-20T10:45:05Z")

</div>


