From ecfdcd4447df28fa71c755e11b05ab9ceb46a576 Mon Sep 17 00:00:00 2001
From: Alessandro Cerioni <acerioni@grandlyon.com>
Date: Sat, 9 Mar 2019 13:35:09 +0100
Subject: [PATCH] Making the indexer robust w/ respect to missing geometry.

---
 7-doc-indexer.py | 34 ++++++++++++++++++----------------
 1 file changed, 18 insertions(+), 16 deletions(-)

diff --git a/7-doc-indexer.py b/7-doc-indexer.py
index 6bf1e2c..86ea635 100644
--- a/7-doc-indexer.py
+++ b/7-doc-indexer.py
@@ -49,22 +49,24 @@ def tag_doc( the_doc ):
     if 'data-fr' in the_doc.keys():
         tag_dict['isSearchable'] = True
 
-        # init
-        tag_dict['isPunctual'] = False
-        tag_dict['isLinear']   = False
-        tag_dict['isAreal']    = False
-
-        # isPunctual?
-        if any( [x in the_doc['data-fr']['geometry']['type'] for x in ['Point', 'MultiPoint']] ):
-            tag_dict['isPunctual'] = True
-
-        # isLinear?
-        if any( [x in the_doc['data-fr']['geometry']['type'] for x in ['LineString', 'MultiLineString']] ):
-            tag_dict['isLinear'] = True
-
-        # isAreal?
-        if any( [x in the_doc['data-fr']['geometry']['type'] for x in ['Polygon', 'MultiPolygon']] ):
-            tag_dict['isAreal'] = True
+        if 'geometry' in the_doc['data-fr'].keys():
+
+            # init
+            tag_dict['isPunctual'] = False
+            tag_dict['isLinear']   = False
+            tag_dict['isAreal']    = False
+
+            # isPunctual?
+            if any( [x in the_doc['data-fr']['geometry']['type'] for x in ['Point', 'MultiPoint']] ):
+                tag_dict['isPunctual'] = True
+
+            # isLinear?
+            if any( [x in the_doc['data-fr']['geometry']['type'] for x in ['LineString', 'MultiLineString']] ):
+                tag_dict['isLinear'] = True
+
+            # isAreal?
+            if any( [x in the_doc['data-fr']['geometry']['type'] for x in ['Polygon', 'MultiPolygon']] ):
+                tag_dict['isAreal'] = True
 
     tagged_doc = {'editorial-metadata': tag_dict, **the_doc}
 
-- 
GitLab