1515)
1616from findthatpostcode .controllers .places import Place
1717from findthatpostcode .metadata import AREA_TYPES
18- from findthatpostcode .settings import S3_BUCKET
18+ from findthatpostcode .settings import (
19+ AREA_INDEX ,
20+ ENTITY_INDEX ,
21+ PLACENAME_INDEX ,
22+ POSTCODE_INDEX ,
23+ S3_BUCKET ,
24+ )
1925from findthatpostcode .utils import ESConfig
2026
2127if TYPE_CHECKING :
2228 from findthatpostcode .controllers .postcodes import Postcode
2329
2430
2531class Areatype (Controller ):
26- es_index = "geo_entity"
32+ es_index = ENTITY_INDEX
2733 url_slug = "areatypes"
2834 areatypes = AREA_TYPES
2935
@@ -98,7 +104,7 @@ def get_areas(
98104 }
99105 }
100106 search_params : dict [str , str | dict | int ] = dict (
101- index = "geo_area" ,
107+ index = AREA_INDEX ,
102108 body = query ,
103109 sort = "_id:asc" ,
104110 )
@@ -144,7 +150,7 @@ def area_types_count(
144150
145151
146152class Area (Controller ):
147- es_index = "geo_area"
153+ es_index = AREA_INDEX
148154 url_slug = "areas"
149155 template = "area.html.j2"
150156 date_fields = ["date_end" , "date_start" ]
@@ -306,7 +312,7 @@ def get_example_postcodes(
306312 }
307313 }
308314 example = es .search (
309- index = "geo_postcode" ,
315+ index = POSTCODE_INDEX ,
310316 body = query ,
311317 size = examples_count , # type: ignore
312318 )
@@ -327,7 +333,7 @@ def get_children(areacode: str, es: Elasticsearch) -> dict:
327333 },
328334 }
329335 children = es .search (
330- index = "geo_area" ,
336+ index = AREA_INDEX ,
331337 body = query ,
332338 size = 100 , # type: ignore
333339 _source_includes = ["code" , "name" , "type" , "active" ], # type: ignore
@@ -424,7 +430,7 @@ def search_areas(
424430 Search for areas based on a name
425431 """
426432 if not es_config :
427- es_config = ESConfig (es_index = "geo_area" )
433+ es_config = ESConfig (es_index = AREA_INDEX )
428434 query = {
429435 "query" : {
430436 "function_score" : {
@@ -489,7 +495,7 @@ def search_areas(
489495 }
490496 if pagination :
491497 result = es .search (
492- index = "geo_area,geo_placename " ,
498+ index = f" { AREA_INDEX } , { PLACENAME_INDEX } " ,
493499 body = query ,
494500 from_ = pagination .from_ , # type: ignore
495501 size = pagination .size , # type: ignore
@@ -498,14 +504,14 @@ def search_areas(
498504 )
499505 else :
500506 result = es .search (
501- index = "geo_area,geo_placename " ,
507+ index = f" { AREA_INDEX } , { PLACENAME_INDEX } " ,
502508 body = query ,
503509 _source_excludes = ["boundary" ], # type: ignore
504510 ignore = [404 ], # type: ignore
505511 )
506512 return_result = []
507513 for a in result .get ("hits" , {}).get ("hits" , []):
508- if a ["_index" ] == "geo_placename" :
514+ if a ["_index" ] == PLACENAME_INDEX :
509515 relationships = {}
510516 if a ["_source" ].get ("areas" , {}).get ("laua" ):
511517 relationships ["areas" ] = [
0 commit comments