Created
          July 2, 2019 18:49 
        
      - 
      
- 
        Save jwenerd/c5a9974daaa71a06d4c2c865293c4fce to your computer and use it in GitHub Desktop. 
    search sql
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | -------------------------------------------------------------------------------------------------------- | |
| # FROM Global Search | |
| SELECT Count(*) | |
| FROM "pg_search_documents" | |
| INNER JOIN | |
| ( | |
| SELECT "pg_search_documents"."id" AS pg_search_id, | |
| (Ts_rank((To_tsvector('simple', COALESCE("pg_search_documents"."content"::text, ''))), (To_tsquery('simple', ''' ' | |
| || 'len' | |
| || ' ''' | |
| || ':*')), 0)) AS rank | |
| FROM "pg_search_documents" | |
| WHERE ((( | |
| To_tsvector('simple', COALESCE("pg_search_documents"."content"::text, ''))) @@ (to_tsquery('simple', ''' ' | |
| || 'len' | |
| || ' ''' | |
| || ':*'))))) AS pg_search_ce9b9dd18c5c0023f2116f | |
| ON "pg_search_documents"."id" = pg_search_ce9b9dd18c5c0023f2116f.pg_search_id | |
| WHERE "pg_search_documents"."searchable_type" = 'Question' | |
| -------------------------------------------------------------------------------------------------------- | |
| # FROM Question Search | |
| SELECT Count(*) | |
| FROM "questions" | |
| INNER JOIN | |
| ( | |
| SELECT "questions"."id" AS pg_search_id, | |
| (Ts_rank((To_tsvector('simple', COALESCE("questions"."title"::text, '')) | |
| || To_tsvector('simple', COALESCE("questions"."searchable_content"::text, ''))), (To_tsquery('simple', ''' ' | |
| || 'len' | |
| || ' ''')), 0)) AS rank | |
| FROM "questions" | |
| WHERE ((( | |
| To_tsvector('simple', COALESCE("questions"."title"::text, '')) | |
| || To_tsvector('simple', COALESCE("questions"."searchable_content"::text, ''))) @@ (to_tsquery('simple', ''' ' | |
| || 'len' | |
| || ' '''))))) AS pg_search_17d5efa695de036a7acb61 | |
| ON "questions"."id" = pg_search_17d5efa695de036a7acb61.pg_search_id | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment