Skip to content

Commit

Permalink
Fix an issue with the postgres indices as they weren't being used pro…
Browse files Browse the repository at this point in the history
…perly
  • Loading branch information
bjpirt committed Feb 26, 2024
1 parent 06bc5fd commit b31d038
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ private void parseFreeText(String freeText) {
conditions.add(cond);
} else {
Condition cond = new Condition();
cond.setAttribute("to_tsvector(json_data::text)");
cond.setAttribute("jsonb_to_tsvector('english', json_data, '[\"all\"]')");
cond.setOperator("@@");
String[] values = {freeText};
cond.setValues(Arrays.asList(values));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
-- Drop the unused text index on the json_data column
DROP INDEX CONCURRENTLY IF EXISTS workflow_index_json_data_text_idx;
-- Create a new index to enable querying the json by attribute and value
CREATE INDEX CONCURRENTLY IF NOT EXISTS workflow_index_json_data_gin_idx ON workflow_index USING GIN (json_data jsonb_path_ops);

-- Drop the incorrectly created indices on the workflow_index that should be on the task_index table
DROP INDEX CONCURRENTLY IF EXISTS task_index_json_data_json_idx;
DROP INDEX CONCURRENTLY IF EXISTS task_index_json_data_text_idx;
-- Create the full text index on the json_data column of the task_index table
CREATE INDEX CONCURRENTLY IF NOT EXISTS task_index_json_data_json_idx ON task_index USING GIN (jsonb_to_tsvector('english', json_data, '["all"]'));
-- Create a new index to enable querying the json by attribute and value
CREATE INDEX CONCURRENTLY IF NOT EXISTS task_index_json_data_gin_idx ON task_index USING GIN (json_data jsonb_path_ops);

0 comments on commit b31d038

Please sign in to comment.