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

[bitnami/postgresql] to_tsquery result discrepancy between bitnami image and official postgres image #76045

Open
quinlanjager opened this issue Jan 7, 2025 · 2 comments
Assignees
Labels
in-progress postgresql tech-issues The user has a technical issue about an application

Comments

@quinlanjager
Copy link

quinlanjager commented Jan 7, 2025

Name and Version

bitnami/postgresql:latest

What architecture are you using?

arm64

What steps will reproduce the bug?

  1. Start up a docker container with bitnami/postgresql:latest (first discovered this running tag 15.4.0 though)
docker run -p 5432:5432 -e POSTGRESQL_PASSWORD=postgres -d bitnami/postgresql
  1. Using your preferred Postgres client connect to server in that docker container (default "postgres" database is fine).
psql -h localhost -p 5432 -U postgres
  1. Login using password "postgres" and execute the following query:
SELECT 
  to_tsvector('pg_catalog.english', 'title here the body text is here'),
  to_tsquery('title & body') as search_query,
  to_tsvector('pg_catalog.english', 'title here the body text is here') @@ to_tsquery('title & body') AS has_match

What is the expected behavior?

        to_tsvector         |  search_query   | has_match 
----------------------------+-----------------+-----------
 'bodi':4 'text':5 'titl':1 | 'titl' & 'bodi' | t

What do you see instead?

        to_tsvector         |   search_query   | has_match
----------------------------+------------------+----------
 'bodi':4 'text':5 'titl':1 | 'title' & 'body' | f

Additional information

The "expected behaviour" was taken from a docker container running the latest official postgres image (was version 17.2). However, I also saw this result using official postgres 15.4, 15.6 and 16.

It might be just a coincidence but I also saw reproduced the "bug" behaviour on an Amazon RDS instance running postgres 15.4.

The query itself is adapted from Postgres' documentation.

@quinlanjager quinlanjager added the tech-issues The user has a technical issue about an application label Jan 7, 2025
@github-actions github-actions bot added the triage Triage is needed label Jan 7, 2025
@quinlanjager
Copy link
Author

quinlanjager commented Jan 7, 2025

Further findings. It seems like the when the official postgres image picked up that my default_text_search_config should be "english" instead of "simple". By creating my query like so to_tsquery('english', 'title & body') I was able to see the expected result. This is a suitable workaround for my purposes.

I still wonder why there is a difference in behaviour. 🤔

@github-actions github-actions bot removed the triage Triage is needed label Jan 8, 2025
@github-actions github-actions bot assigned fmulero and unassigned javsalgar Jan 8, 2025
@fmulero
Copy link
Collaborator

fmulero commented Jan 13, 2025

Hi @quinlanjager, thanks for using bitnami containers

I tried to reproduce the issue you share but I couldn't. These are the steps I followed and the results:

$ docker run --rm --name bitnami -d -e ALLOW_EMPTY_PASSWORD=yes bitnami/postgresql
a1f309fd0898c7cf6b76d1f8337f624a796fe7abedc365b62779ff05ce5e75b6
$ docker exec -it bitnami psql -U postgres
psql (17.0)
Type "help" for help.

postgres=# SELECT
postgres-#   to_tsvector('pg_catalog.english', 'title here the body text is here'),
postgres-#   to_tsquery('title & body') as search_query,
postgres-#   to_tsvector('pg_catalog.english', 'title here the body text is here') @@ to_tsquery('title & body') AS has_match
postgres-# ;
        to_tsvector         |   search_query   | has_match
----------------------------+------------------+-----------
 'bodi':4 'text':5 'titl':1 | 'title' & 'body' | f
(1 row)

postgres=#

Are you using an existing database? Not sure if the issue could be relate to your locale configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in-progress postgresql tech-issues The user has a technical issue about an application
Projects
None yet
Development

No branches or pull requests

4 participants