By JSON.stringify into JSON
This is a nested json
var keywords = $(this).val(); JSON.stringify({query:{match_phrase:{companyname:keywords}}})
It can also be written in this format:
var keywords = $(this).val();
var json='{"query":{"match_phrase":{"companyname":"'+keywords+'"}}}'