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

function to_tsquery(tsquery) does not exist #69

Open
riccardocagnasso opened this issue Apr 5, 2018 · 4 comments
Open

function to_tsquery(tsquery) does not exist #69

riccardocagnasso opened this issue Apr 5, 2018 · 4 comments

Comments

@riccardocagnasso
Copy link

sqlalchemy.exc.ProgrammingError: (psycopg2.ProgrammingError) function to_tsquery(tsquery) does not exist
LINE 6: ...r, '')) || coalesce(identity_4.search_vector)) @@ to_tsquery...

I get this error when searching a on a combined search vector like

        combined_search_vector = User.search_vector | func.coalesce(
            Person.search_vector, u'')

        query = query.outerjoin(Person).filter(combined_search_vector.match(
            func.tsq_parse(search_query)))

        return query
@riccardocagnasso
Copy link
Author

I tracked the code. Long story short, you shouldn't use "match" but the provided "search" function with the vector parameter.

Ok, but you really should update the documentation mate.

@cgle
Copy link

cgle commented May 24, 2018

query = query.filter(combined_search_vector.search(func.tsq_parse(term)))
I use this but it says:
'BinaryExpression' object nor 'comparator_factory' object has an attribute 'search'

@sonnybaker
Copy link

sonnybaker commented Oct 16, 2018

Resolution for anyone stuck with this:

search_query = 'test'
combined_search_vector = (Project.search_vector | db.func.coalesce(Document.search_vector, u''))

projects = (
    db.session.query(Project)
    .join(Document)
    .filter(
        combined_search_vector.match(search_query)
    )
)

@xenups
Copy link

xenups commented Sep 28, 2020

actually, it doesn't need a long way just instead of using a filter use it this way:

search_query = 'test'
combined_search_vector = (Project.search_vector | db.func.coalesce(Document.search_vector, u''))
projects = db.session.query(Project)
found_items = search(search_query, combined_search_vector, projects)

the documentation needs to be update

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

4 participants