combine_fields#

geodesic.boson.combine_fields(new_field, fields, separator='', sprintf='', input_collection=None, output_collection=None)[source]#

Combine fields in the properties of a search response.

Parameters:
  • new_field (str) – name of the new field to create

  • fields (List[str]) – fields to combine

  • separator (str, optional) – separator to use when combining fields. Defaults to “ “.

  • sprintf (str, optional) – sprintf format to use when combining fields. This uses golang

  • instance (format strings to format the fields into one combined string field. For)

:param : :param “%d.2 %s” would print “2.00 dollars” if the field values were 2 and “dollars”.: :param For more information about the formatting see https: //pkg.go.dev/fmt. :param All fields must have values for the sprintf to be executed. Defaults to “”.: :param input_collection: name of the input collection to apply transform to.

Defaults to None (all collections)

Parameters:

output_collection (str, optional) – name of the virtual collection that the transform will be applied to. Defaults to None (no virtual collection created)

Examples

>>> # Combine the fields STATE_FIPS and COUNTY_FIPS into a new field called FIPS
>>> transform = combine_fields(
...     new_field="FIPS",
...     fields=["STATE_FIPS", "COUNTY_FIPS"],
...     separator=""
... )
>>> # Combine the fields STATE_FIPS and COUNTY_FIPS into a new field called FIPS
>>> transform = combine_fields(
...     new_field="FIPS",
...     fields=["STATE_FIPS", "COUNTY_FIPS"],
...     sprintf="%02d%03d"
... )