Searching for phrase which will return partial text in the field

Hi,

I am learning elasticsearch and tried few queries like match, match phrase, search, fuzzy etc.
Whenever we search for any text ES returns the document containing that text. I am having a different requirement where I want to search for a text or a phrase and the result should be a range of text which means matching phrase along with couple of words before and after the phrase.

Ex.
Document is having following text
A DFA is defined as an abstract mathematical concept, but is often implemented in hardware and software for solving various specific problems. For example, a DFA can model software that decides whether or not online user input such as email addresses are valid

If I search for a word let say "software"

then it should return
often implemented in hardware and software for solving various specific problems

few words before and after the word software should be returned.

Is this available in elasticsearch? If yes can someone suggest what should be used for getting such results.

Hi,
I think highlighting is what you're looking for :
https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-highlighting.html

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