Query match_phrase in Nested filed

Hello, I have an index with a nested field called lines with values
"text": "Other congestive heart failure"
"text": "Staging is recommended"
I want to make a query by match_phrase within the lines field where the phrase is "Congestive Heart failure Staging is recommended"

Hey there, unfortunately nested fields actually index the content as separate documents, so you can't perform that type of search out of the box.

You could experiment with a boolean query that searched for each field, but given your question I'm not 100% sure that would meet your needs.

Are you sure you need a nested field for this use case? Or could you index this content in another field for this type of text search?

Yes, I have a content field where I store all the text, but each item in the nested field stores line coordinates, and when I search for the complete phrase I want to highlight the lines where that phrase appears

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