How do I tag ways that are part of a relation during osm2pgsql import?

Hi everyone.

I’m importing OSM data using osm2pgsql, and am using a custom lua script to tag ways.

I want to tag ways that are part of relation. In my particular case, I want to tag ways that are part of a bicycle route, so that I can use this information in my rendering styles.

The osm2pgsql documentation mentions relations in a function called filter_tags_relation_member, but this seems to support returning additional information only about the relation, not about the member ways.

Alternatively, I could run data updates after import, but because of continuous updates from OSM, that quickly seems to become a patchwork of tasks.

I’m quite new to this, but I am a developer, so if there’s some way to achieve this during import that isn’t obvious to me, I’d appreciate if someone would point me in the right direction.

Thank you in advance.

You mention the filter_tags_relation_member function. It looks like you are using the “old” pgsql output, which is not developed any more. Please have a look at the flex output instead. It is much more flexible and has the functionality you need, specifically you need two-stage processing. Also have a look at this example config which shows how to work with route relations.