server/src/app/Console/Commands/IndexDocuments.php
changeset 498 265992e5b379
parent 497 f3474aeec884
child 506 8a5bb4b48b85
--- a/server/src/app/Console/Commands/IndexDocuments.php	Mon Feb 06 10:03:33 2017 +0100
+++ b/server/src/app/Console/Commands/IndexDocuments.php	Mon Feb 06 13:23:39 2017 +0100
@@ -103,6 +103,15 @@
                                 ]
                             ]
                         ],
+                        'description' => [
+                            'type' => 'string',
+                            'fields' => [
+                                'french' => [
+                                    'type' => 'string',
+                                    'analyzer' => 'french'
+                                ]
+                            ]
+                        ],
                         'date' => [ 'type' => 'date', 'index' => 'not_analyzed'],
                         'geonames_hierarchy' => [ 'type' => 'string', 'index' => 'not_analyzed'],
                         'geonames_country' => ['type' => 'string', 'index' => 'not_analyzed'],
@@ -524,6 +533,21 @@
         }, []);
     }
 
+    private function getDescriptions($doc) {
+        return array_reduce($doc->getDescriptions(), function($res, $desc) {
+            $val = null;
+            if(is_string($desc)) {
+                $val = $desc;
+            } elseif($desc instanceof Literal) {
+                $val = $desc->getValue();
+            }
+            if(!empty($val)) {
+                array_push($res, $val);
+            }
+            return $res;
+        }, []);
+    }
+
     private function getDocBody($doc) {
         list($geonamesCountry, $geonamesHierarchy) = $this->getGeonamesHierarchy($doc);
         return [
@@ -537,6 +561,7 @@
             'geonames_country' => $geonamesCountry,
             'geonames_hierarchy' => $geonamesHierarchy,
             'subject' => $this->getSubjects($doc),
+            'description' => $this->getDescriptions($doc),
         ];
     }