From a8d675e47f384beb98f893236fecaa67ba08ea10 Mon Sep 17 00:00:00 2001
From: Antonin Coquet <ext.sopra.acoquet@grandlyon.com>
Date: Wed, 12 May 2021 11:22:29 +0200
Subject: [PATCH] feat: add structure description to ES fields

---
 src/structures/interfaces/structure-search-body.interface.ts | 1 +
 src/structures/services/structures-search.service.ts         | 4 +++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/structures/interfaces/structure-search-body.interface.ts b/src/structures/interfaces/structure-search-body.interface.ts
index 24d759193..14857a413 100644
--- a/src/structures/interfaces/structure-search-body.interface.ts
+++ b/src/structures/interfaces/structure-search-body.interface.ts
@@ -5,4 +5,5 @@ export interface StructureSearchBody {
   structureName: string;
   structureType: string;
   address: Address;
+  description: string;
 }
diff --git a/src/structures/services/structures-search.service.ts b/src/structures/services/structures-search.service.ts
index e809c58f9..f75cb5a69 100644
--- a/src/structures/services/structures-search.service.ts
+++ b/src/structures/services/structures-search.service.ts
@@ -20,6 +20,7 @@ export class StructuresSearchService {
         structureType: structure.structureType,
         structureId: structure._id,
         address: structure.address,
+        description: structure.description,
       },
     });
     return structure;
@@ -64,7 +65,7 @@ export class StructuresSearchService {
           query_string: {
             analyze_wildcard: 'true',
             query: searchString,
-            fields: ['structureName^5', 'structureType^5', 'address.street', 'address.commune^5'],
+            fields: ['structureName^5', 'structureType^5', 'address.street', 'address.commune^5', 'description'],
             fuzziness: 'AUTO',
           },
         },
@@ -84,6 +85,7 @@ export class StructuresSearchService {
           structureType: structure.structureType,
           structureId: id,
           address: structure.address,
+          description: structure.description,
         },
       },
     });
-- 
GitLab