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

Queries not including results with () #3

Closed
WinteryFox opened this issue Nov 23, 2019 · 3 comments
Closed

Queries not including results with () #3

WinteryFox opened this issue Nov 23, 2019 · 3 comments

Comments

@WinteryFox
Copy link
Owner

Simply searching for dog currently does not include the actual word for dog (犬) because its glossary entry contains some text between brackets in its actual gloss entry. dog (Canis (lupus) familiaris) I could simply throw in a wildcard to fix this however that would make the queries turn into seconds instead of milliseconds. Maybe an index could fix this?

@vendethiel
Copy link

Something like that is possible: name >= 'dog' AND name < 'doh'.

In general tho, if Postgresql is able to tell that a LIKE doesn't start with a wildcard, it'll be able without an issue to transform it to a BETWEEN-like clause, so you don't lose that much performance.
Of course if it's parameterized, it might be an issue.

@WinteryFox
Copy link
Owner Author

I've currently fixed this with the following index (on the dev branch)
CREATE INDEX IF NOT EXISTS trgm_gloss_index ON gloss (regexp_replace(txt, '\s\(.*\)', ''));
it's performant and simply removes everything between brackets, not sure if it's the optimal solution but it does work.

@WinteryFox
Copy link
Owner Author

Will be fixed with next release to master

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