Skip to content

Commit

Permalink
Bug fix: Dynamic indices field map check
Browse files Browse the repository at this point in the history
  • Loading branch information
pdphilip committed Oct 4, 2024
1 parent 0e0a781 commit d7dd23f
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions src/DSL/Bridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -1391,19 +1391,21 @@ private function _formatAggs($key, $values)
private function _parseFieldMap(array $mapping): array
{
$fields = [];
$mapping = $mapping[$this->index]['mappings'];
foreach ($mapping as $key => $item) {
// Check if 'mapping' key exists and is not empty
if (! empty($item['mapping'])) {
foreach ($item['mapping'] as $details) {
if (isset($details['type'])) {
$fields[$key] = $details['type'];
}
// Check if nested fields exist within the field's details
if (isset($details['fields'])) {
foreach ($details['fields'] as $subField => $subDetails) {
$subFieldName = $key.'.'.$subField;
$fields[$subFieldName] = $subDetails['type'];
$mapping = reset($mapping);
if (! empty($mapping['mappings'])) {
foreach ($mapping['mappings'] as $key => $item) {
// Check if 'mapping' key exists and is not empty
if (! empty($item['mapping'])) {
foreach ($item['mapping'] as $details) {
if (isset($details['type'])) {
$fields[$key] = $details['type'];
}
// Check if nested fields exist within the field's details
if (isset($details['fields'])) {
foreach ($details['fields'] as $subField => $subDetails) {
$subFieldName = $key.'.'.$subField;
$fields[$subFieldName] = $subDetails['type'];
}
}
}
}
Expand Down

0 comments on commit d7dd23f

Please sign in to comment.