How to extract a portion of text based on keywords


I have a huge size of document per record and I need to extract a portion of document content based on keyword per record. I am wondering if there is a feature available in Elasticsearch to allow me to define portion (e.g. x number of words after the key words or n bytes proceeding the keyword or something similar) to be returned?



I am not sure whether this really fits your use case but it sounds to me that maybe highlighters can help.