I found a workaround, but even if it works fine, I believe there should be some other way, so I'm still expecting some answers, if you please.
My workaround goes as follows:
I remove the markups I placed in my highlighted hit into a new variable:
a=result.gsub(/<\/?result>/,"")
fetch the corresponding field with Active Record
model=Model.find(hit.primary_key)
and replace the unformatted text (variable a
) with the formatted (variable result
)
newresult=model.body.gsub(a,result)
thus resulting to the desired outcome.