Creating index using dynamic SQL
createIndex := 'CREATE INDEX idx_'
    || Fulltable_name
    || '_properties_crosspr_gist ON public.'
    || Fulltable_name
    || ' 
    USING gist (properties) 
    WHERE properties @&gt; $$"block_level_0"=&gt;"cerber-head"$$::hstore 
      AND properties @&gt; $$"block_level_1"=&gt;"head"$$::hstore 
      AND properties @&gt; $$"block_level_2"=&gt;"cross-news"$$::hstore 
      AND properties ? $$block_level_5$$::text 
      AND NOT properties ? $$block_level_6$$::text';