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

Simplify wildcard JSON searching #947

Merged
merged 3 commits into from
Jul 4, 2024
Merged

Conversation

psrok1
Copy link
Member

@psrok1 psrok1 commented Jul 1, 2024

Your checklist for this pull request

  • I've read the contributing guideline.
  • I've tested my changes by building and running the project, and testing changed functionality (if applicable)
  • I've added automated tests for my change (if applicable, optional)
  • I've updated documentation to reflect my change (if applicable)

What is the current behaviour?

JSON search code is pretty complicated because it assumes that wildcard search that is not a full-text search (with wildcards on both sides *value*) can also search for nested objects, so it needs to look for two possible combinations of escaping:

  • quoted values {"key": {"current_dir": "C:\\Windows"}} so cfg.key:*C:\\Windows* needs to search for LIKE '%C:\\\\Windows' as the value returned by json_path_query(cfg, '$.key') #>> '{}' is {"current_dir": "C:\\Windows"}
  • unquoted values {"key": "C:\Windows"} so cfg.key:"C:\\Windows*" needs to search for LIKE "C:\\Windows%" as the value returned by json_path_query(cfg, '$.key') #>> '{}' is C:\Windows

What is the new behaviour?

We just assume that nested objects can be searched only with full-text search. When search is not full-text, we assume that we match only against literal, which simplifies query.

@psrok1 psrok1 force-pushed the feature/simplify-json-searching branch from 8d2e477 to 6966da0 Compare July 4, 2024 13:57
@psrok1 psrok1 merged commit 3aeb719 into master Jul 4, 2024
12 checks passed
@psrok1 psrok1 deleted the feature/simplify-json-searching branch July 4, 2024 14:32
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

Successfully merging this pull request may close these issues.

1 participant