Skip to content

Commit 17c57c3

Browse files
committed
Update search.py
Ensure keyword is used for the geo-facets
1 parent 5c3d9ed commit 17c57c3

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

app/elasticsearch/search.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737
"dct_creator_sm",
3838
"schema_provider_s",
3939
"dct_accessRights_s",
40+
"geo_country",
41+
"geo_region",
42+
"geo_county",
4043
}
4144

4245

@@ -98,15 +101,15 @@ def get_facet_aggregation_config(facet_name: str) -> dict:
98101
"size": DEFAULT_FACET_SIZE,
99102
},
100103
"geo_country": {
101-
"field": "geo_country",
104+
"field": "geo_country.keyword",
102105
"size": GEO_COUNTRY_FACET_SIZE,
103106
},
104107
"geo_region": {
105-
"field": "geo_region",
108+
"field": "geo_region.keyword",
106109
"size": GEO_REGION_FACET_SIZE,
107110
},
108111
"geo_county": {
109-
"field": "geo_county",
112+
"field": "geo_county.keyword",
110113
"size": GEO_COUNTY_FACET_SIZE,
111114
},
112115
}
@@ -536,9 +539,10 @@ async def search_resources(
536539
"terms": {"field": "gbl_georeferenced_b", "size": DEFAULT_FACET_SIZE}
537540
},
538541
# Spatial facet aggregations with configurable sizes
539-
"geo_country": {"terms": {"field": "geo_country", "size": GEO_COUNTRY_FACET_SIZE}},
540-
"geo_region": {"terms": {"field": "geo_region", "size": GEO_REGION_FACET_SIZE}},
541-
"geo_county": {"terms": {"field": "geo_county", "size": GEO_COUNTY_FACET_SIZE}},
542+
# Note: These fields are text with keyword subfields in the actual index
543+
"geo_country": {"terms": {"field": "geo_country.keyword", "size": GEO_COUNTRY_FACET_SIZE}},
544+
"geo_region": {"terms": {"field": "geo_region.keyword", "size": GEO_REGION_FACET_SIZE}},
545+
"geo_county": {"terms": {"field": "geo_county.keyword", "size": GEO_COUNTY_FACET_SIZE}},
542546
}
543547

544548
selected_aggs = (

0 commit comments

Comments
 (0)