Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support aliases config in api.targets.layers_by_source #1417

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Joxit
Copy link
Member

@Joxit Joxit commented Apr 7, 2020

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 😅

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 😄

IMO, the safe replace is not required in my new function 🤷‍♂️

@Joxit Joxit requested a review from missinglink September 2, 2020 08:50
@@ -114,7 +114,7 @@ module.exports.tests.interfaces = function(test, common) {
whosonfirst: [ 'continent', 'empire', 'country', 'dependency', 'macroregion',
'region', 'locality', 'localadmin', 'macrocounty', 'county', 'macrohood',
'borough', 'neighbourhood', 'microhood', 'disputed', 'venue', 'postalcode',
'continent', 'ocean', 'marinearea' ]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seeing double 👀

@missinglink
Copy link
Member

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:

  1. We want to open things up for non-WOF admin layers, as per Spatial service
  2. One effect of doing so will be that the coarse alias will not include these other sources
  3. Setting them manually sucks
  4. 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.

@missinglink
Copy link
Member

Oh this also requires a rebase to get the GH Actions tests working again

@Joxit Joxit force-pushed the joxit/feat/type-mapping branch from d1bfe9a to a94d892 Compare January 21, 2021 09:01
@Joxit
Copy link
Member Author

Joxit commented Jan 21, 2021

Yes, you understood correctly

  1. ✔️
  2. When we use sources=source_with_coarse then layers=coarse and layers=locality,localadmin are not available without this PR
  3. The coarse list is too long for me, I know, I'm lazy 😅
  4. Since the automatic configuration is based on ES, this will not work with spatial

updated 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants