This page describes how to convert from a JSON path in a document to a flat field name for Lucene indexing
Just replace the dot .
with an underscore _
. Convert cases to lowercase. Convert underscore separated to no separation.
doc.name -> name
doc.patient.name -> patient_name
doc.patient.referenceNo -> patient_referenceno
doc.patient.reference_no -> patient_referenceno // you should not have underscore separated in Javascript anyway