The Inner Hits Field is used for nested field matches in Elasticsearch or OpenSearch, this field allows you to display the hit with its corresponding inner hits.

Schema Details

PropertyTypeDescriptionRequiredDefaultEnum
typestringThe type of field.Noinner_hitsinner_hits
labelstring/nullLabel to show for this field.Nonull
css_styleobject/nullStyle to apply in the HTML of the UI.Nonull
css_classstring/nullCSS class to apply in the HTML component.Nonull
translatestring/nullTranslation key for the field.Nonull
translate_labelstring/nullTranslation key for the label.Nonull
analyticsobject/nullAnalytics configuration.Nonull
if_not_existstring/nullShow only if the specified field doesn't exist.Nonull
if_existstring/nullShow only if the specified field does exist.Nonull
only_on_highlightbooleanShow only when the value is highlighted.Nofalse
displayarray/any/nullValue from the field.Nonull
fieldstringName of the inner_hits.Yes

field_highlightstring/nullPath to highlight field from which to retrieve the value, in case it is not the same as the field parameter (in JMESPath format).Nonull
defaultanyDefault value to use in case no value was found for the field.Nonull
transformarray/string/nullList of transformations to apply to the displayed values.Nonull
suffixstring/nullSuffix to append to the value or values.Nonull
prefixstring/nullPrefix to append to the value or values.Nonull
suffix_labelstring/nullSuffix to append to the label of the field.Nonull
prefix_labelstring/nullPrefix to append to the label of the field.Nonull
sortstring/booleanSort order for values in an array.Nofalseasc, desc
uniquebooleanIf the values are in an array, remove the duplicates.Nofalse
show_blankbooleanIf there is no value, or value is null, and show_blank is true, keep the field.Nofalse
replacementstring/nullReplacement string for matches in the transformations Transformation.REPLACE_FIRST, Transformation.REPLACE_LAST, and Transformation.REPLACE_ALL.Nonull
patternstring/nullPattern used to look for matches in the transformations Transformation.REPLACE_FIRST, Transformation.REPLACE_LAST, and Transformation.REPLACE_ALL.Nonull
body_gridarray/array/nullBody defined as a grid (list of lists).Nonull
body_listarray/object/nullBody defined as a single list.Nonull

Example JSON Representation

{
  "type": "inner_hits",
  "label": "Related Items",
  "display": ,
  "field": "related_items",
  "field_highlight": null,
  "default": null,
  "transform": null,
  "suffix": null,
  "prefix": null,
  "suffix_label": null,
  "prefix_label": null,
  "sort": false,
  "unique": false,
  "show_blank": false,
  "replacement": null,
  "pattern": null,
  "body_grid": [
	{
	  "type": "text",
	  "label": "Name",
	  "display": "Will",
	  "field": "name"
	},
	{
	  "type": "text",
	  "label": "Name",
	  "display": "Grace",
	  "field": "name"
	},
],
  "body_list": null
}


Code Example of Usage

inner_hits_field_example = InnerHits(field='field', 
	body_grid=[
		[TextField(...), UrlField(...), BoolField(...)],
		[TextField(...), BoolField],
		.
		.
		.
	],
)


or

inner_hits_field_example = InnerHits(field='field', body_list=[TextField(...), UrlField(...), BoolField(...), ...])
  • No labels