1

In PostgreSQL query, how can I filter the results by using any record that tags with a key like %building%

something like:

..
where 
    Table.tags ? '%building%'

I didn't find an answer within the postgresql documentation (https://www.postgresql.org/docs/9.6/static/hstore.html)

2

You need to create a set of the keys in order to be able to compare them using like.

Something like:

select *
from the_table t
where exists (select * 
              from skeys(t.tags) as x(tagname)
              where x.tagname like '%building%');

But this is not going to be fast.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.