visuddhinanda 1 неделя назад
Родитель
Сommit
97293262d6

+ 11 - 0
api-v12/app/DTO/Search/AggregationDTO.php

@@ -23,4 +23,15 @@ class AggregationDTO
             buckets: array_map(fn($bucket) => BucketDTO::fromArray($bucket), $data['buckets']),
         );
     }
+    public function toArray(): array
+    {
+        return [
+            'doc_count_error_upper_bound' => $this->doc_count_error_upper_bound,
+            'sum_other_doc_count' => $this->sum_other_doc_count,
+            'buckets' => array_map(
+                fn(BucketDTO $bucket) => $bucket->toArray(),
+                $this->buckets
+            ),
+        ];
+    }
 }

+ 10 - 0
api-v12/app/DTO/Search/AggregationsDTO.php

@@ -20,4 +20,14 @@ class AggregationsDTO
             category: AggregationDTO::fromArray($data['category']),
         );
     }
+
+    public function toArray(): array
+    {
+        return [
+            'granularity'   => $this->granularity->toArray(),
+            'resource_type' => $this->resource_type->toArray(),
+            'language'      => $this->language->toArray(),
+            'category'      => $this->category->toArray(),
+        ];
+    }
 }

+ 7 - 0
api-v12/app/DTO/Search/BucketDTO.php

@@ -16,4 +16,11 @@ class BucketDTO
             doc_count: $data['doc_count'],
         );
     }
+    public function toArray(): array
+    {
+        return [
+            'key' => $this->key,
+            'doc_count' => $this->doc_count,
+        ];
+    }
 }

+ 11 - 1
api-v12/app/DTO/Search/HitItemDTO.php

@@ -6,12 +6,16 @@ class HitItemDTO
 {
     public function __construct(
         public string $id,
+        public string $resId,
         public float $score,
         public string $content,
         public string $title,
         public string $path,
         public array $category,
         public string $highlight,
+        public string $updated,
+        public string $type,
+        public string $language,
 
     ) {}
 
@@ -36,7 +40,9 @@ class HitItemDTO
         $titleArray = [];
         if (is_array($source['title'])) {
             foreach ($source['title'] as $key => $value) {
-                $titleArray[] = $value;
+                if (strpos($key, 'suggest') === false) {
+                    $titleArray[] = $value;
+                }
             }
         }
         $title = implode('', $titleArray);
@@ -56,6 +62,10 @@ class HitItemDTO
             path: $source['path'] ?? '',
             category: $category,
             highlight: implode('', $highlightArray),
+            updated: $source['updated_at'],
+            type: $source['resource_type'],
+            language: $source['language'],
+            resId: $source['resource_id'],
         );
     }