Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQL to update full text search has a bad query #74

Closed
iandees opened this issue Dec 22, 2018 · 2 comments
Closed

SQL to update full text search has a bad query #74

iandees opened this issue Dec 22, 2018 · 2 comments

Comments

@iandees
Copy link
Member

iandees commented Dec 22, 2018

This line in the full text search update SQL doesn't execute:

UPDATE search_metadata SET document = document || to_tsvector('simple', coalesce(sub.code, ' ')) WHERE text4 = sub.geoidlower(text2) = '500' AND type = 'profile';

psql:/home/ubuntu/census-api/full-text-search/metadata_script.sql:167: ERROR:  missing FROM-clause entry for table "sub"
LINE 1: ...ment = document || to_tsvector('simple', coalesce(sub.code, ...
                                                             ^

It's not clear to me what sub should be referring to here.

@JoeGermuska
Copy link
Member

copy paste error. The correct SQL is:

UPDATE search_metadata 
    SET document = document || to_tsvector('simple', coalesce(subquery.code, ' ')) 
    FROM
        (select regex.geoid, regex.match[2] || '-' || regex.match[1] as code from 
        (select text4 as geoid, regexp_matches(text1, 'Congressional District (\d+), (..)') as match 
         from search_metadata where type = 'profile' and text2 = '500') regex
    ) subquery
    WHERE search_metadata.text4 = subquery.geoid;

@JoeGermuska
Copy link
Member

ah, i see that the right SQL is in there too... so really just a c/p error

JoeGermuska added a commit that referenced this issue Jan 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants