Skip to content

Commit

Permalink
Issue #3354: Added dynamic field name handling for CI Elasticsearch.
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanhaerter authored and svenoe committed May 3, 2024
1 parent b06f1ed commit 3d9f3f9
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions Kernel/System/Elasticsearch.pm
Original file line number Diff line number Diff line change
Expand Up @@ -654,14 +654,31 @@ sub ConfigItemSearch {

my $FulltextFields = $ConfigObject->Get('Elasticsearch::ConfigItemSearchFields');
my @SearchFields = (
@{ $FulltextFields->{Basic} // [] },
@{ $FulltextFields->{DynamicField} // [] },
@{ $FulltextFields->{Basic} // [] },
);

if ( $FulltextFields->{Attachments} ) {
push @SearchFields, ( 'Attachments.Content', 'Attachments.Filename' );
}

# handle dynamic fields
if ( $FulltextFields->{DynamicField} ) {
my $DynamicFieldObject = $Kernel::OM->Get('Kernel::System::DynamicField');

DYNAMICFIELD:
for my $DynamicFieldName ( @{ $FulltextFields->{DynamicField} } ) {
my $DynamicField = $DynamicFieldObject->DynamicFieldGet(
Name => $DynamicFieldName,
);
next DYNAMICFIELD unless IsHashRefWithData($DynamicField);

# add all config item dynamic fields
if ( $DynamicField->{ObjectType} eq 'ITSMConfigItem' ) {
push @SearchFields, "DynamicField_$DynamicFieldName";
}
}
}

push @Musts, {
query_string => {
fields => \@SearchFields,
Expand Down

0 comments on commit 3d9f3f9

Please sign in to comment.