title: Will trigram index on multiple columns make search faster and how to make such search properly?
body: <p>Let's assume I have table with multiple columns. For instance:</p>
  
  <pre><code>id int
  name text
  surname text
  cars json
  </code></pre>
  
  <p>example record would be </p>
  
  <pre><code>+----+------+---------+------------------------------------+
  | id | name | surname |              cars                  |
  +----+------+---------+------------------------------------+
  |  1 | John | Doe     | {"values":["Ford", "BMW", "Fiat"]} |
  +----+------+---------+------------------------------------+
  </code></pre>
  
  <p>I want to search all this table data for relevance like this:</p>
  
  <pre><code>select *,
         similarity(
            'Malcolm Joe likes Ferrary, but hates BMW',
            (name || (cars -&gt;&gt; 'values') || surname)
         ) sim
  from public.test_table
  where similarity(
           'Malcolm Joe likes Ferrary, but hates BMW',
           (name || (cars -&gt;&gt; 'values') || surname)
        ) &gt; 0.05
  order by sim desc;
  </code></pre>
  
  <p>Is there any way to speed up this search? Creating a trigram index? If so - how to create it better? on one column, on each column, on a concatenation expression? Also, I haven't understand which type of index is better - GIN or GiST. I've read that GIN is usually better for regular full text search, but GiST is better for trigram search. Is that correct?</p>
  
  <p>I also wanted to ask if there is better way to write the above query? </p>
  
  <p>If anyone wonders why I chose trigram, and not regular full text search - it's because search strings will come from processing some user input, so there can be mistakes or even cases when english 'o' or 'c' is replaced by cirillic letters. my database records or search can also contain alphanumeric data, which is also better processed with trigram.</p>