# onSearch request creation

**URL:** <https://discuss.elastic.co/t/onsearch-request-creation/373104>\
**Category:** Elastic Search\
**Created:** [January 13, 2025, 12:21am UTC](https://discuss.elastic.co/t/onsearch-request-creation/373104 "2025-01-13T00:21:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mike\_vogel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mike_vogel/32/138978_2.png) [@mike\_vogel](https://discuss.elastic.co/u/mike_vogel)\
**Post date:** [January 13, 2025, 12:21am UTC](https://discuss.elastic.co/t/onsearch-request-creation/373104/1 "2025-01-13T00:21:30Z")

</div>

I'm using Elastic Cloud and the Elastic Search UI. I'm trying to understand how the default search request is created by the onSearch function. For example I'm trying to see why the search-term is queried as a 'should' multi\_match. I want this to be a 'must'. I did it by changing the requestBody just before the query was sent. I'm hoping there is less fragile way to do it.

Is there documentation on how the onSearch function creates requests? If not can you point me at the code to review to understand it..

---

<div class="post-metadata">

**Author:** ![carly.richmond](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/carly.richmond/32/104935_2.png) [@carly.richmond](https://discuss.elastic.co/u/carly.richmond)\
**Post date:** [January 16, 2025, 2:17pm UTC](https://discuss.elastic.co/t/onsearch-request-creation/373104/2 "2025-01-16T14:17:39Z")

</div>

Hi @mike_vogel,

Can you share the code snippet you have where you are overriding the `requestBody`? Are you using a particular connector?

I couldn't quite track down the exact code in [the GitHub repo](https://github.com/search?q=repo%3Aelastic%2Fsearch-ui%20onSearch&type=code) to tell you how to override this as I've not managed to do it myself. But @joemcelroy may know as he maintains the project.

Let us know!

---

<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:** [February 13, 2025, 2:17pm UTC](https://discuss.elastic.co/t/onsearch-request-creation/373104/3 "2025-02-13T14:17:55Z")

</div>

Closed on February 13, 2025, 2:17pm UTC

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