Search API query with user input in body

Versions (relevant - OpenSearch/Dashboard/Server OS/Browser):
1.3

Describe the issue:
Im trying to create a search function using AWS lambda. I want the field name and field value to be variable and from a user input. Is this possible?
this is what i have so far:

const index = {Index_name}
const { Field1, Value1 } = req.query.JSON;
const query2 = {
query: {
match_phrase: {
fields: {
query: Field1, {
query: Value1
},
},
},
},
};

const param = {
index: index,
body: query2,
};

const osSearch = await search(param);
console.log(‘osSearch Output:’, osSearch);