# Writing queries with Search UI

**URL:** <https://discuss.elastic.co/t/writing-queries-with-search-ui/325712>\
**Category:** Elasticsearch\
**Created:** [February 16, 2023, 10:01am UTC](https://discuss.elastic.co/t/writing-queries-with-search-ui/325712 "2023-02-16T10:01:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pierre-Olivier\_BEAU](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pierre-olivier_beau/32/116672_2.png) [@Pierre-Olivier\_BEAU](https://discuss.elastic.co/u/Pierre-Olivier_BEAU)\
**Post date:** [February 16, 2023, 10:01am UTC](https://discuss.elastic.co/t/writing-queries-with-search-ui/325712/1 "2023-02-16T10:01:23Z")

</div>

Hello all,

I am currently researching the best way to send complex queries from a front-end interface to a custom api which will then send the query to Elasticsearch (using search UI-ES-connector).

Search UI seems the best fit however, I have a hard time seeing how could I translate the queries I am sending to Elasticsearch into React.js. Most queries sent to ES contains filters, aggregations, sub-aggs, nested aggs and even reverse aggs. I wonder if it's even doable and that perhaps it should be done separately. Any feedback would be appreciated, thank you for your time. Here is one of the queries:

```auto
{
	"size": 0,
	"query": {
		"bool": {
			"filter": [
				{
					"exists": {
						"field": "numero"
					}
				},
				{
					"range": {
						"status": {
							"gte": "7",
							"lte": "8"
						}
					}
				}
			]
		}
	},
	"aggs": {
		"OT": {
			"terms": {
				"field": "status",
				"missing": "-1"
			},
			"aggs": {
				"DATE": {
					"date_histogram": {
						"field": "completed_date"
					},
					"aggs": {
						"type_id": {
							"terms": {
								"field": "type_id",
								"missing": "-1",
								"size": 100
							}
						},
						"hierarchy": {
							"terms": {
								"field": "hierarchy",
								"missing": "N/A",
								"size": 100
							}
						},
						"empl_id": {
							"terms": {
								"field": "empl_id",
								"missing": "-1",
								"size": 100
							}
						}
					}
				}
			}
		}
	}
}

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [March 16, 2023, 10:02am UTC](https://discuss.elastic.co/t/writing-queries-with-search-ui/325712/2 "2023-03-16T10:02:15Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
