Returning full elasticsearch document containing a provided String

I'm having an index named as recipe in which I have a document like this

{
"took" : 4,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : 2,
"max_score" : 1.0,
"hits" : [
{
"_index" : "recipe",
"_type" : "default",
"_id" : "AWyW-Vo64wb-rcXk0BW7",
"_score" : 1.0,
"_source" : {
"[{"Timings":{"totalTime":"PT10M","cookTime":"PT5M","id":null,"prepTime":"PT5M"},"SkillLevel":"Easy","Keywords":["Cannellini bean","Cannellini beans","Mash","Beans","Super healthy","Pulses","5-a-day","Low fat","Diet","Dieting","Side dish","Bangers and mash","Sausage and mash","Texture","Fireworks","Pesto","Easy","Vegetarian","Healthy","Bonfire Night"],"Category":["Side dish","Dinner"],"Nutrition":"per serving","MakingMethod":["Heat the oil in a large saucepan. Add the beans and cook for 3-4 mins until hot through. Lightly mash with a potato masher for a chunky texture. Stir through the pesto and season. To serve, drizzle with a little olive oil, if you like."],"Cousine":"British","Channel":"Recipe","Rating":{"bestRating":5,"ratingValue":4.625,"id":null,"ratingCount":8,"worstRating":1},"Ingredients":["1 tbsp olive oil, plus a drizzle to serve (optional)","2 x 400g cans cannellini beans, rinsed and drained","2 tbsp pesto"],"Servings":"Serves 4","Title":"Bean & pesto mash","Publication":{"eval":false,"additionalInfo":"","id":null,"published":"","value":"","url":""},"recipe_url":"https://www.techno-homes.com/recipes/1742637/bean-and-pesto-mash","Author":{"eval":false,"additionalInfo":"Recipe from Good Food magazine, ","description":"Substitute potatoes with pulses for a healthy alternative mash with a chunky texture","id":null,"published":"November 2011","value":"Techno Homes","url":"https://www.techno-homes.com/publication/good-food-0"},"id":79,"NutritionContents":{"kcal":183,"sugars":"3g","salt":"0.84g","carbs":"25g","protein":"11g","fat":"5g","saturates":"1g","id":0,"fibre":"7g"}}]" : ""
}
},
{
"_index" : "recipe",
"_type" : "default",
"_id" : "AWyXHv2W4wb-rcXk0BW9",
"_score" : 1.0,
"_source" : {
"[{"Timings":{"totalTime":"PT10M","cookTime":"PT5M","id":null,"prepTime":"PT5M"},"SkillLevel":"Easy","Keywords":["Cannellini bean","Cannellini beans","Mash","Beans","Super healthy","Pulses","5-a-day","Low fat","Diet","Dieting","Side dish","Bangers and mash","Sausage and mash","Texture","Fireworks","Pesto","Easy","Vegetarian","Healthy","Bonfire Night"],"Category":["Side dish","Dinner"],"Nutrition":"per serving","MakingMethod":["Heat the oil in a large saucepan. Add the beans and cook for 3-4 mins until hot through. Lightly mash with a potato masher for a chunky texture. Stir through the pesto and season. To serve, drizzle with a little olive oil, if you like."],"Cousine":"British","Channel":"Recipe","Rating":{"bestRating":5,"ratingValue":4.625,"id":null,"ratingCount":8,"worstRating":1},"Ingredients":["1 tbsp olive oil, plus a drizzle to serve (optional)","2 x 400g cans cannellini beans, rinsed and drained","2 tbsp pesto"],"Servings":"Serves 4","Title":"Jamshaid","Publication":{"eval":false,"additionalInfo":"","id":null,"published":"","value":"","url":""},"recipe_url":"https://www.techno-homes.com/recipes/1742637/bean-and-pesto-mash","Author":{"eval":false,"additionalInfo":"Recipe from Good Food magazine, ","description":"Substitute potatoes with pulses for a healthy alternative mash with a chunky texture","id":null,"published":"November 2011","value":"Techno Homes","url":"https://www.techno-homes.com/publication/good-food-0"},"id":80,"NutritionContents":{"kcal":183,"sugars":"3g","salt":"0.84g","carbs":"25g","protein":"11g","fat":"5g","saturates":"1g","id":0,"fibre":"7g"}}]" : ""
}
}
]
}
}

I want to perform a search over this. The search string should be searched in the whole document and the part which contains that string should be returned from the document.
I've tried multiple ways but can't figure it out. How am I supposed to do that? Please help me figure this out. I've posted a question over stackoverflow as well which is available over this link

Welcome!

Please format your code, logs or configuration files using </> icon as explained in this guide and not the citation button. It will make your post more readable.

Or use markdown style like:

```
CODE
```

This is the icon to use if you are not using markdown format:

There's a live preview panel for exactly this reasons.

Lots of people read these forums, and many of them will simply skip over a post that is difficult to read, because it's just too large an investment of their time to try and follow a wall of badly formatted text.
If your goal is to get an answer to your questions, it's in your interest to make it as easy to read and understand as possible.
Please update your post.

About your question, I'd probably use a multimatch query or a simple query string query and then I'd use highlighter.
Or I'd use copy_to feature to copy all content within one single field and then highlight that field.

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