diff --git a/7-doc-indexer.py b/7-doc-indexer.py index 6bf1e2c6c743eb19f8980a1ec8ef97e8fb56b81d..86ea6353c22b22f035fc4ddea017d30eb108c4fa 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}