(field_path, is_known=False)
return ret
Generate a script field string for easier querying.
    field_path: is the path.to.property.name in the _source
    is_known: if true, then query as is, if false, then it's a dynamically mapped item,
    so put on the #value property at the end.
Generate a script field string for easier querying.
    field_path: is the path.to.property.name in the _source
    is_known: if true, then query as is, if false, then it's a dynamically mapped item,
    so put on the #value property at the end.
Generate a script field string for easier querying . field_path : is the path . to . property . name in the _source is_known : if true then query as is if false then it s a dynamically mapped item so put on the #value property at the end .
def get_report_script_field(field_path, is_known=False):
    """
    Generate a script field string for easier querying.
    field_path: is the path.to.property.name in the _source
    is_known: if true, then query as is, if false, then it's a dynamically mapped item,
    so put on the #value property at the end.
    """
    property_split = field_path.split('.')
    property_path = '_source%s' % ''.join("['%s']" % x for x in property_split)
    if is_known:
        script_string = property_path
    else:
        full_script_path = "%s['#value']" % property_path
        script_string = """if (%(prop_path)s != null) { %(value_path)s; }
        else { null; }""" % {
            'prop_path': property_path,
            'value_path': full_script_path
        }

    ret = {"script": script_string}
    return ret
def get_report_script_field ( field_path , is_known = False ) : property_split = field_path . split ( '.' ) property_path = '_source%s' % '' . join ( "['%s']" % x for x in property_split ) if is_known : script_string = property_path else : full_script_path = "%s['#value']" % property_path script_string = """if (%(prop_path)s != null) { %(value_path)s; }
        else { null; }""" % { 'prop_path' : property_path , 'value_path' : full_script_path } ret = { "script" : script_string } return ret