Mocking ElasticSearch with Postman

Archived topic — some details may be out of date.
Mock servers built from saved collection examples are still supported. Postman now also has code-based mocks: JavaScript request handlers plus a config.yaml, stored as files in your Git repository, which you can run locally or deploy. Create one in the app, or use the Postman CLI to generate one from an OpenAPI spec, collection or dataset (postman mock generate) and run it (postman mock run). See About mocks and Create a mock.
Working with an AI coding agent? The Postman plugin can build and run mocks for you.
For current help, see the Postman docs, try the free Postman tools (no account needed), or join us on Discord.

Hi everyone,

I’m wondering if there is a way how to get a response from a postman mocked server based on the request body. I have read about matching algoritm how it works but still want to ask if there is some other possibility.

Real life example:
I have a search service web api that generates a http requests to the ElasticSearch service. The search service is called from a client (e.g. user wants to find something in the material catalog). I want to ensure that the search service functionality wont be brake by anyone else so I’m using postman tests with postman mocking service.
I made some test cases and saw what requests are firing to ElasticSearch so I can make a postman examples and create a mock server. However it is generating the same endpoint address for every call to ElasticSearch - it only differs in body request so I will get same response every time.
I can’t use x-mock-response-name since the request to the mocking server is happening outside of the postman tests.

I hope following illustration will help to imagine the situation.

Any help is greatly appriciated!