If you plan on doing frequent searches against a specific HL7 segment/field, you can speed up the searches significantly by using Ensemble's "search tables" mechanism for adding an index for that field.

http://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=...

Fields indexed in the search table are listed in the dropdown box on the message viewer search, or can be queried using SQL by joining EnsLib_HL7.SearchTable:

select msg.ID,msg.TimeCreated,
       msg.DocType,
       msgHdr.SourceConfigName,
       msgHdr.TargetConfigName,
       msg.RawContent 
from EnsLib_HL7.SearchTable srchTbl
join enslib_hl7.message msg on msg.id=srchTbl.docid 
join Ens.MessageHeader msgHdr on msgHdr.MessageBodyId=srchTbl.docid
where  (srchTbl.propid=(select propid from Ens_Config.SearchTableProp where classextent='EnsLib.HL7.SearchTable' and name='PatientSSN')
       and srchTbl.propvalue = '123-25-4612')
       and msgHdr.SourceConfigName='HL7.File.In'