Support aliases config in `api.targets.layers_by_source`
Use-cases
coarse is a pretty cool alias, it includes all admin layers in one shoot. Following pelias/config#127, I wondered how custom targets work. Setting value on layers_by_source is quite annoying when you have a custom layers that are like WOF. Why don't we use coarse ? This is the main subject of my PR.
Attempted Solutions
I try to add coarse to a custom layer, but it didn't work. The error was funny :sweat_smile:
The targets config looks like this
{
"targets": {
"layers_by_source": {
"source_with_coarse": ["coarse"]
}
}
}
If I use locality for example (which is in the coarse list)
GET /v1/search?sources=source_with_coarse&text=Paris&layers=locality
{
"errors": [
"You have specified both the `sources` and `layers` parameters in a combination that will return no results: the test source has nothing in the locality layer"
]
}
And if I use the value in the configuration:
GET /v1/search?sources=source_with_coarse&text=Paris&layers=coarse
{
"errors": [
"You have specified both the `sources` and `layers` parameters in a combination that will return no results: the test source has nothing in the continent layer",
"You have specified both the `sources` and `layers` parameters in a combination that will return no results: the test source has nothing in the empire layer",
"You have specified both the `sources` and `layers` parameters in a combination that will return no results: the test source has nothing in the country layer",
"You have specified both the `sources` and `layers` parameters in a combination that will return no results: the test source has nothing in the dependency layer",
"You have specified both the `sources` and `layers` parameters in a combination that will return no results: the test source has nothing in the macroregion layer",
"You have specified both the `sources` and `layers` parameters in a combination that will return no results: the test source has nothing in the region layer",
"You have specified both the `sources` and `layers` parameters in a combination that will return no results: the test source has nothing in the locality layer",
"You have specified both the `sources` and `layers` parameters in a combination that will return no results: the test source has nothing in the localadmin layer",
"You have specified both the `sources` and `layers` parameters in a combination that will return no results: the test source has nothing in the macrocounty layer",
"You have specified both the `sources` and `layers` parameters in a combination that will return no results: the test source has nothing in the county layer",
"You have specified both the `sources` and `layers` parameters in a combination that will return no results: the test source has nothing in the macrohood layer",
"You have specified both the `sources` and `layers` parameters in a combination that will return no results: the test source has nothing in the borough layer",
"You have specified both the `sources` and `layers` parameters in a combination that will return no results: the test source has nothing in the neighbourhood layer",
"You have specified both the `sources` and `layers` parameters in a combination that will return no results: the test source has nothing in the microhood layer",
"You have specified both the `sources` and `layers` parameters in a combination that will return no results: the test source has nothing in the disputed layer",
"You have specified both the `sources` and `layers` parameters in a combination that will return no results: the test source has nothing in the postalcode layer",
"You have specified both the `sources` and `layers` parameters in a combination that will return no results: the test source has nothing in the ocean layer",
"You have specified both the `sources` and `layers` parameters in a combination that will return no results: the test source has nothing in the marinearea layer"
]
}
Proposal
I chose to update the type mapping at startup and replace aliases by the list of layers. Now all work as expected :smile:
IMO, the safe replace is not required in my new function :man_shrugging:
I'm struggling to wrap my head around this, it all seems good to me but I don't really understand it. Can you please remind me what it's about?
What I think it's about:
- We want to open things up for non-WOF admin layers, as per Spatial service
- One effect of doing so will be that the
coarsealias will not include these other sources - Setting them manually sucks
- Setting them automatically doesn't work
Does that kinda sum it up? I guess the bits I'm not 100% clear on are 3 and 4.
Oh this also requires a rebase to get the GH Actions tests working again
Yes, you understood correctly
- :heavy_check_mark:
- When we use
sources=source_with_coarsethenlayers=coarseandlayers=locality,localadminare not available without this PR - The coarse list is too long for me, I know, I'm lazy :sweat_smile:
- Since the automatic configuration is based on ES, this will not work with spatial
updated :+1: